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
with:
version: v1.45.2
version: v1.49.0
mod-tidy:
runs-on: ubuntu-20.04

View File

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

View File

@ -1,5 +1,5 @@
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
RPI32_IMAGE = balenalib/raspberrypi3: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
import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"reflect"
"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 {
return true, err
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import (
"crypto/tls"
"encoding/hex"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
@ -383,7 +383,7 @@ func (c *Client) downloadSegment(innerCtx context.Context, segmentURI string) ([
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 {
return nil, err
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import (
)
// 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 as the preceding chunk.
type Chunk2 struct {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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