update golangci-lint

This commit is contained in:
aler9
2021-05-23 18:51:21 +02:00
parent 4d8b7bfa43
commit 99323ba740
20 changed files with 27 additions and 32 deletions
+1
View File
@@ -6,6 +6,7 @@ linters:
- gochecknoinits
- gocritic
- gofmt
- gofumpt
- golint
- misspell
- prealloc
+12 -4
View File
@@ -26,12 +26,20 @@ $(blank)
endef
mod-tidy:
docker run --rm -it -v $(PWD):/s amd64/$(BASE_IMAGE) \
sh -c "apk add git && cd /s && GOPROXY=direct go get && go mod tidy"
docker run --rm -it -v $(PWD):/s -w /s amd64/$(BASE_IMAGE) \
sh -c "apk add git && GOPROXY=direct go get && go mod tidy"
define DOCKERFILE_FORMAT
FROM $(BASE_IMAGE)
RUN apk add --no-cache git
RUN GO111MODULE=on go get mvdan.cc/gofumpt
endef
export DOCKERFILE_FORMAT
format:
docker run --rm -it -v $(PWD):/s amd64/$(BASE_IMAGE) \
sh -c "cd /s && find . -type f -name '*.go' | xargs gofmt -l -w -s"
echo "$$DOCKERFILE_FORMAT" | docker build -q . -f - -t temp
docker run --rm -it -v $(PWD):/s -w /s temp \
sh -c "find . -type f -name '*.go' | xargs gofumpt -l -w"
define DOCKERFILE_TEST
FROM amd64/$(BASE_IMAGE)
-2
View File
@@ -162,7 +162,6 @@ func New(
pathName string,
pathMan PathMan,
parent Parent) *Converter {
ctx, ctxCancel := context.WithCancel(ctxParent)
c := &Converter{
@@ -425,7 +424,6 @@ func (c *Converter) runInner(innerCtx context.Context) error {
}
c.tsMutex.Unlock()
}
} else {
if !curTSFile.firstPacketWritten {
continue
-1
View File
@@ -51,7 +51,6 @@ func New(
pathMan *pathman.PathManager,
parent Parent,
) (*Server, error) {
ln, err := net.Listen("tcp", address)
if err != nil {
return nil, err
+1 -1
View File
@@ -57,7 +57,7 @@ func New(level Level, destinations map[Destination]struct{}, filePath string) (*
if _, ok := destinations[DestinationFile]; ok {
var err error
lh.file, err = os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
lh.file, err = os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
lh.Close()
return nil, err
-1
View File
@@ -38,7 +38,6 @@ func New(
stats *stats.Stats,
parent Parent,
) (*Metrics, error) {
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, err
-3
View File
@@ -117,7 +117,6 @@ func New(
wg *sync.WaitGroup,
stats *stats.Stats,
parent Parent) *Path {
ctx, ctxCancel := context.WithCancel(ctxParent)
pa := &Path{
@@ -171,7 +170,6 @@ func (pa *Path) run() {
if pa.conf.Source == "redirect" {
pa.source = &sourceRedirect{}
} else if pa.hasExternalSource() && !pa.conf.SourceOnDemand {
pa.startExternalSource()
}
@@ -339,7 +337,6 @@ func (pa *Path) startExternalSource() {
&pa.sourceWg,
pa.stats,
pa)
} else if strings.HasPrefix(pa.conf.Source, "rtmp://") {
pa.source = rtmpsource.New(
pa.ctx,
-2
View File
@@ -76,7 +76,6 @@ func New(
pathConfs map[string]*conf.PathConf,
stats *stats.Stats,
parent Parent) *PathManager {
ctx, ctxCancel := context.WithCancel(ctxParent)
pm := &PathManager{
@@ -361,7 +360,6 @@ func (pm *PathManager) authenticate(
pathUser string,
pathPass string,
) error {
// validate ip
if pathIPs != nil && ip != nil {
if !ipEqualOrInRange(ip, pathIPs) {
-1
View File
@@ -27,7 +27,6 @@ func New(
address string,
parent Parent,
) (*PPROF, error) {
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, err
-1
View File
@@ -24,7 +24,6 @@ func New(
tracks gortsplib.Tracks,
onFrame func(int, gortsplib.StreamType, []byte),
) *RTCPSenderSet {
s := &RTCPSenderSet{
onFrame: onFrame,
terminate: make(chan struct{}),
+2 -3
View File
@@ -95,7 +95,6 @@ func New(
nconn net.Conn,
pathMan PathMan,
parent Parent) *Conn {
ctx, ctxCancel := context.WithCancel(ctxParent)
c := &Conn{
@@ -218,7 +217,8 @@ func (c *Conn) runRead(ctx context.Context) error {
ValidateCredentials: func(authMethods []headers.AuthMethod, pathUser string, pathPass string) error {
return c.validateCredentials(pathUser, pathPass, query)
},
Res: sres})
Res: sres,
})
res := <-sres
if res.Err != nil {
@@ -527,7 +527,6 @@ func (c *Conn) validateCredentials(
pathPass string,
query url.Values,
) error {
if query.Get("user") != pathUser ||
query.Get("pass") != pathPass {
return readpublisher.ErrAuthCritical{
-1
View File
@@ -52,7 +52,6 @@ func New(
stats *stats.Stats,
pathMan *pathman.PathManager,
parent Parent) (*Server, error) {
l, err := net.Listen("tcp", address)
if err != nil {
return nil, err
+1 -1
View File
@@ -53,7 +53,6 @@ func New(
wg *sync.WaitGroup,
stats *stats.Stats,
parent Parent) *Source {
ctx, ctxCancel := context.WithCancel(ctxParent)
s := &Source{
@@ -72,6 +71,7 @@ func New(
s.wg.Add(1)
go s.run()
return s
}
-2
View File
@@ -70,7 +70,6 @@ func New(
stats *stats.Stats,
conn *gortsplib.ServerConn,
parent Parent) *Conn {
c := &Conn{
rtspAddress: rtspAddress,
readTimeout: readTimeout,
@@ -190,7 +189,6 @@ func (c *Conn) ValidateCredentials(
pathName string,
req *base.Request,
) error {
// reset authValidator every time the credentials change
if c.authValidator == nil || c.authUser != pathUser || c.authPass != pathPass {
c.authUser = pathUser
-1
View File
@@ -90,7 +90,6 @@ func New(
stats *stats.Stats,
pathMan *pathman.PathManager,
parent Parent) (*Server, error) {
ctx, ctxCancel := context.WithCancel(ctxParent)
s := &Server{
-1
View File
@@ -58,7 +58,6 @@ func New(
sc *gortsplib.ServerConn,
pathMan PathMan,
parent Parent) *Session {
s := &Session{
rtspAddress: rtspAddress,
protocols: protocols,
+1 -1
View File
@@ -60,7 +60,6 @@ func New(
wg *sync.WaitGroup,
stats *stats.Stats,
parent Parent) *Source {
ctx, ctxCancel := context.WithCancel(ctxParent)
s := &Source{
@@ -83,6 +82,7 @@ func New(
s.wg.Add(1)
go s.run()
return s
}
+2 -1
View File
@@ -112,7 +112,8 @@ func (p *program) Log(level logger.Level, format string, args ...interface{}) {
countReaders := atomic.LoadInt64(p.stats.CountReaders)
p.logger.Log(level, "[%d/%d] "+format, append([]interface{}{
countPublishers, countReaders}, args...)...)
countPublishers, countReaders,
}, args...)...)
}
func (p *program) run() {
+1 -1
View File
@@ -863,7 +863,7 @@ wait
require.NoError(t, err)
defer os.Remove(onDemandFile)
err = os.Chmod(onDemandFile, 0755)
err = os.Chmod(onDemandFile, 0o755)
require.NoError(t, err)
t.Run("describe", func(t *testing.T) {
+6 -4
View File
@@ -60,9 +60,11 @@ func newContainer(image string, name string, args []string) (*container, error)
exec.Command("docker", "kill", "rtsp-simple-server-test-"+name).Run()
exec.Command("docker", "wait", "rtsp-simple-server-test-"+name).Run()
cmd := []string{"docker", "run",
cmd := []string{
"docker", "run",
"--name=rtsp-simple-server-test-" + name,
"rtsp-simple-server-test-" + image}
"rtsp-simple-server-test-" + image,
}
cmd = append(cmd, args...)
ecmd := exec.Command(cmd[0], cmd[1:]...)
ecmd.Stdout = nil
@@ -189,7 +191,7 @@ func TestHotReloading(t *testing.T) {
" runOnInit: echo aaa\n"+
" test4:\n"+
" runOnInit: echo bbb\n"),
0644)
0o644)
require.NoError(t, err)
defer os.Remove(confPath)
@@ -217,7 +219,7 @@ func TestHotReloading(t *testing.T) {
" test3:\n"+
" test4:\n"+
" runOnInit: echo bbb\n"),
0644)
0o644)
require.NoError(t, err)
time.Sleep(1 * time.Second)