update golangci-lint

This commit is contained in:
aler9
2022-09-17 21:19:45 +02:00
parent 7f7a6e2200
commit f1fb00b80f
29 changed files with 44 additions and 34 deletions

View File

@@ -15,7 +15,7 @@ jobs:
- uses: golangci/golangci-lint-action@v3 - uses: golangci/golangci-lint-action@v3
with: with:
version: v1.45.2 version: v1.49.0
mod-tidy: mod-tidy:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@@ -1,4 +1,3 @@
linters: linters:
enable: enable:
- bodyclose - bodyclose

View File

@@ -1,5 +1,5 @@
BASE_IMAGE = golang:1.18-alpine3.15 BASE_IMAGE = golang:1.18-alpine3.15
LINT_IMAGE = golangci/golangci-lint:v1.45.2 LINT_IMAGE = golangci/golangci-lint:v1.49.0
NODE_IMAGE = node:16-alpine3.15 NODE_IMAGE = node:16-alpine3.15
RPI32_IMAGE = balenalib/raspberrypi3:buster-run RPI32_IMAGE = balenalib/raspberrypi3:buster-run
RPI64_IMAGE = balenalib/raspberrypi3-64:buster-run RPI64_IMAGE = balenalib/raspberrypi3-64:buster-run

View File

@@ -1,10 +1,10 @@
// Package conf contains the struct that holds the configuration of the software.
package conf package conf
import ( import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"reflect" "reflect"
"strings" "strings"
@@ -46,7 +46,7 @@ func loadFromFile(fpath string, conf *Conf) (bool, error) {
} }
} }
byts, err := ioutil.ReadFile(fpath) byts, err := os.ReadFile(fpath)
if err != nil { if err != nil {
return true, err return true, err
} }

View File

@@ -4,7 +4,6 @@ import (
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"io" "io"
"io/ioutil"
"os" "os"
"testing" "testing"
"time" "time"
@@ -17,7 +16,7 @@ import (
) )
func writeTempFile(byts []byte) (string, error) { func writeTempFile(byts []byte) (string, error) {
tmpf, err := ioutil.TempFile(os.TempDir(), "rtsp-") tmpf, err := os.CreateTemp(os.TempDir(), "rtsp-")
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@@ -1,3 +1,4 @@
// Package confwatcher contains a configuration watcher.
package confwatcher package confwatcher
import ( import (

View File

@@ -1,7 +1,6 @@
package confwatcher package confwatcher
import ( import (
"io/ioutil"
"os" "os"
"testing" "testing"
"time" "time"
@@ -10,7 +9,7 @@ import (
) )
func writeTempFile(byts []byte) (string, error) { func writeTempFile(byts []byte) (string, error) {
tmpf, err := ioutil.TempFile(os.TempDir(), "confwatcher-") tmpf, err := os.CreateTemp(os.TempDir(), "confwatcher-")
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@@ -1,3 +1,4 @@
// Package core contains the main struct of the software.
package core package core
import ( import (

View File

@@ -3,7 +3,6 @@ package core
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"io/ioutil"
"net" "net"
"os" "os"
"os/exec" "os/exec"
@@ -120,7 +119,7 @@ func (c *container) wait() int {
} }
func writeTempFile(byts []byte) (string, error) { func writeTempFile(byts []byte) (string, error) {
tmpf, err := ioutil.TempFile(os.TempDir(), "rtsp-") tmpf, err := os.CreateTemp(os.TempDir(), "rtsp-")
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -225,15 +224,14 @@ func TestCorePathRunOnDemand(t *testing.T) {
doneFile := filepath.Join(os.TempDir(), "ondemand_done") doneFile := filepath.Join(os.TempDir(), "ondemand_done")
srcFile := filepath.Join(os.TempDir(), "ondemand.go") srcFile := filepath.Join(os.TempDir(), "ondemand.go")
err := ioutil.WriteFile(srcFile, []byte(` err := os.WriteFile(srcFile, []byte(`
package main package main
import ( import (
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"io/ioutil" "github.com/aler9/gortsplib"
"github.com/aler9/gortsplib"
) )
func main() { func main() {
@@ -261,7 +259,7 @@ func main() {
signal.Notify(c, syscall.SIGINT) signal.Notify(c, syscall.SIGINT)
<-c <-c
err = ioutil.WriteFile("`+doneFile+`", []byte(""), 0644) err = os.WriteFile("`+doneFile+`", []byte(""), 0644)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -394,7 +392,7 @@ func TestCorePathRunOnReady(t *testing.T) {
func TestCoreHotReloading(t *testing.T) { func TestCoreHotReloading(t *testing.T) {
confPath := filepath.Join(os.TempDir(), "rtsp-conf") confPath := filepath.Join(os.TempDir(), "rtsp-conf")
err := ioutil.WriteFile(confPath, []byte("paths:\n"+ err := os.WriteFile(confPath, []byte("paths:\n"+
" test1:\n"+ " test1:\n"+
" publishUser: myuser\n"+ " publishUser: myuser\n"+
" publishPass: mypass\n"), " publishPass: mypass\n"),
@@ -421,7 +419,7 @@ func TestCoreHotReloading(t *testing.T) {
require.EqualError(t, err, "bad status code: 401 (Unauthorized)") require.EqualError(t, err, "bad status code: 401 (Unauthorized)")
}() }()
err = ioutil.WriteFile(confPath, []byte("paths:\n"+ err = os.WriteFile(confPath, []byte("paths:\n"+
" test1:\n"), " test1:\n"),
0o644) 0o644)
require.NoError(t, err) require.NoError(t, err)

View File

@@ -1,7 +1,7 @@
package core package core
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@@ -68,7 +68,7 @@ func TestMetrics(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode) require.Equal(t, http.StatusOK, res.StatusCode)
bo, err := ioutil.ReadAll(res.Body) bo, err := io.ReadAll(res.Body)
require.NoError(t, err) require.NoError(t, err)
vals := make(map[string]string) vals := make(map[string]string)

View File

@@ -1,3 +1,4 @@
// Package externalcmd allows to launch external commands.
package externalcmd package externalcmd
import ( import (

View File

@@ -7,7 +7,7 @@ import (
"crypto/tls" "crypto/tls"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@@ -383,7 +383,7 @@ func (c *Client) downloadSegment(innerCtx context.Context, segmentURI string) ([
return nil, fmt.Errorf("bad status code: %d", res.StatusCode) return nil, fmt.Errorf("bad status code: %d", res.StatusCode)
} }
byts, err := ioutil.ReadAll(res.Body) byts, err := io.ReadAll(res.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"context" "context"
"io" "io"
"io/ioutil"
"log" "log"
"net" "net"
"net/http" "net/http"
@@ -80,7 +79,7 @@ y++U32uuSFiXDcSLarfIsE992MEJLSAynbF1Rsgsr3gXbGiuToJRyxbIeVy7gwzD
`) `)
func writeTempFile(byts []byte) (string, error) { func writeTempFile(byts []byte) (string, error) {
tmpf, err := ioutil.TempFile(os.TempDir(), "rtsp-") tmpf, err := os.CreateTemp(os.TempDir(), "rtsp-")
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@@ -1,3 +1,4 @@
// Package fmp4 contains a fMP4 writer.
package fmp4 package fmp4
import ( import (

View File

@@ -1,3 +1,4 @@
// Package mpegts contains a MPEG-TS writer.
package mpegts package mpegts
import ( import (

View File

@@ -1,3 +1,4 @@
// Package hls contains a HLS muxer and client implementation.
package hls package hls
import ( import (

View File

@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"context" "context"
"io" "io"
"io/ioutil"
"regexp" "regexp"
"testing" "testing"
"time" "time"
@@ -127,7 +126,7 @@ func TestMuxerVideoAudio(t *testing.T) {
}) })
require.NoError(t, err) require.NoError(t, err)
byts, err := ioutil.ReadAll(m.File("index.m3u8", "", "", "").Body) byts, err := io.ReadAll(m.File("index.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
if ca == "mpegts" { if ca == "mpegts" {
@@ -146,7 +145,7 @@ func TestMuxerVideoAudio(t *testing.T) {
"stream.m3u8\n", string(byts)) "stream.m3u8\n", string(byts))
} }
byts, err = ioutil.ReadAll(m.File("stream.m3u8", "", "", "").Body) byts, err = io.ReadAll(m.File("stream.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
var ma []string var ma []string
@@ -461,7 +460,7 @@ func TestMuxerVideoOnly(t *testing.T) {
}) })
require.NoError(t, err) require.NoError(t, err)
byts, err := ioutil.ReadAll(m.File("index.m3u8", "", "", "").Body) byts, err := io.ReadAll(m.File("index.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
if ca == "mpegts" { if ca == "mpegts" {
@@ -480,7 +479,7 @@ func TestMuxerVideoOnly(t *testing.T) {
"stream.m3u8\n", string(byts)) "stream.m3u8\n", string(byts))
} }
byts, err = ioutil.ReadAll(m.File("stream.m3u8", "", "", "").Body) byts, err = io.ReadAll(m.File("stream.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
var ma []string var ma []string
@@ -688,7 +687,7 @@ func TestMuxerAudioOnly(t *testing.T) {
}) })
require.NoError(t, err) require.NoError(t, err)
byts, err := ioutil.ReadAll(m.File("index.m3u8", "", "", "").Body) byts, err := io.ReadAll(m.File("index.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
if ca == "mpegts" { if ca == "mpegts" {
@@ -707,7 +706,7 @@ func TestMuxerAudioOnly(t *testing.T) {
"stream.m3u8\n", string(byts)) "stream.m3u8\n", string(byts))
} }
byts, err = ioutil.ReadAll(m.File("stream.m3u8", "", "", "").Body) byts, err = io.ReadAll(m.File("stream.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
var ma []string var ma []string
@@ -929,7 +928,7 @@ func TestMuxerDoubleRead(t *testing.T) {
}) })
require.NoError(t, err) require.NoError(t, err)
byts, err := ioutil.ReadAll(m.File("stream.m3u8", "", "", "").Body) byts, err := io.ReadAll(m.File("stream.m3u8", "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
re := regexp.MustCompile(`^#EXTM3U\n` + re := regexp.MustCompile(`^#EXTM3U\n` +
@@ -944,10 +943,10 @@ func TestMuxerDoubleRead(t *testing.T) {
ma := re.FindStringSubmatch(string(byts)) ma := re.FindStringSubmatch(string(byts))
require.NotEqual(t, 0, len(ma)) require.NotEqual(t, 0, len(ma))
byts1, err := ioutil.ReadAll(m.File(ma[2], "", "", "").Body) byts1, err := io.ReadAll(m.File(ma[2], "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
byts2, err := ioutil.ReadAll(m.File(ma[2], "", "", "").Body) byts2, err := io.ReadAll(m.File(ma[2], "", "", "").Body)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, byts1, byts2) require.Equal(t, byts1, byts2)
} }

View File

@@ -1,3 +1,4 @@
// Package logger contains a logger implementation.
package logger package logger
import ( import (

View File

@@ -1,6 +1,7 @@
//go:build !windows //go:build !windows
// +build !windows // +build !windows
// Package rlimit contains a function to raise rlimit.
package rlimit package rlimit
import ( import (

View File

@@ -1,6 +1,7 @@
//go:build !rpicamera //go:build !rpicamera
// +build !rpicamera // +build !rpicamera
// Package rpicamera allows to interact with a Raspberry Pi Camera.
package rpicamera package rpicamera
import ( import (

View File

@@ -1,3 +1,4 @@
// Package bytecounter contains a reader/writer that allows to count bytes.
package bytecounter package bytecounter
import ( import (

View File

@@ -1,3 +1,4 @@
// Package chunk implements RTMP chunks.
package chunk package chunk
import ( import (

View File

@@ -5,7 +5,7 @@ import (
) )
// Chunk2 is a type 2 chunk. // Chunk2 is a type 2 chunk.
// Neither the stream ID nor the // Neither the stream ID nor the
// message length is included; this chunk has the same stream ID and // message length is included; this chunk has the same stream ID and
// message length as the preceding chunk. // message length as the preceding chunk.
type Chunk2 struct { type Chunk2 struct {

View File

@@ -1,3 +1,4 @@
// Package rtmp implements a RTMP connection.
package rtmp package rtmp
import ( import (

View File

@@ -1,3 +1,4 @@
// Package h264conf contains a H264 configuration parser.
package h264conf package h264conf
import ( import (

View File

@@ -1,3 +1,4 @@
// Package handshake contains the RTMP handshake mechanism.
package handshake package handshake
import ( import (

View File

@@ -1,3 +1,4 @@
// Package message contains a RTMP message reader/writer.
package message package message
import ( import (

View File

@@ -1,3 +1,4 @@
// Package rawmessage contains a RTMP raw message reader/writer.
package rawmessage package rawmessage
import ( import (

View File

@@ -1,3 +1,4 @@
// main executable.
package main package main
import ( import (