Skip to content

Commit

Permalink
update golangci-lint (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Jan 3, 2024
1 parent 7bb211d commit 3937359
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: golangci/golangci-lint-action@v3
with:
version: v1.55.0
version: v1.55.2

go-mod-tidy:
runs-on: ubuntu-20.04
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
linters:
enable:
- asciicheck
- bidichk
- bodyclose
- dupl
- errorlint
- exportloopref
- gochecknoinits
- gocritic
Expand All @@ -13,6 +16,7 @@ linters:
- prealloc
- revive
- unconvert
- tparallel
- wastedassign
- whitespace

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BASE_IMAGE = golang:1.21-alpine3.18
LINT_IMAGE = golangci/golangci-lint:v1.55.0
LINT_IMAGE = golangci/golangci-lint:v1.55.2

.PHONY: $(shell ls)

Expand Down
2 changes: 1 addition & 1 deletion pkg/codecs/h264/dts_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (d *DTSExtractor) extractInner(au [][]byte, pts time.Duration) (time.Durati
var spsp SPS
err := spsp.Unmarshal(nalu)
if err != nil {
return 0, false, fmt.Errorf("invalid SPS: %v", err)
return 0, false, fmt.Errorf("invalid SPS: %w", err)
}
d.sps = nalu
d.spsp = &spsp
Expand Down
4 changes: 2 additions & 2 deletions pkg/codecs/h265/dts_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ func (d *DTSExtractor) extractInner(au [][]byte, pts time.Duration) (time.Durati
var spsp SPS
err := spsp.Unmarshal(nalu)
if err != nil {
return 0, fmt.Errorf("invalid SPS: %v", err)
return 0, fmt.Errorf("invalid SPS: %w", err)
}
d.spsp = &spsp

case NALUType_PPS_NUT:
var ppsp PPS
err := ppsp.Unmarshal(nalu)
if err != nil {
return 0, fmt.Errorf("invalid PPS: %v", err)
return 0, fmt.Errorf("invalid PPS: %w", err)
}
d.ppsp = &ppsp

Expand Down
2 changes: 1 addition & 1 deletion pkg/formats/fmp4/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (i *Init) Unmarshal(r io.ReadSeeker) error {
var c mpeg4audio.Config
err := c.Unmarshal(spec)
if err != nil {
return nil, fmt.Errorf("invalid MPEG-4 Audio configuration: %s", err)
return nil, fmt.Errorf("invalid MPEG-4 Audio configuration: %w", err)
}

curTrack.Codec = &CodecMPEG4Audio{
Expand Down
6 changes: 3 additions & 3 deletions pkg/formats/fmp4/init_track.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (track *InitTrack) marshal(w *mp4Writer) error {
av1SequenceHeader = &av1.SequenceHeader{}
err = av1SequenceHeader.Unmarshal(codec.SequenceHeader)
if err != nil {
return fmt.Errorf("unable to parse AV1 sequence header: %v", err)
return fmt.Errorf("unable to parse AV1 sequence header: %w", err)
}

width = av1SequenceHeader.Width()
Expand All @@ -111,7 +111,7 @@ func (track *InitTrack) marshal(w *mp4Writer) error {
h265SPS = &h265.SPS{}
err = h265SPS.Unmarshal(codec.SPS)
if err != nil {
return fmt.Errorf("unable to parse H265 SPS: %v", err)
return fmt.Errorf("unable to parse H265 SPS: %w", err)
}

width = h265SPS.Width()
Expand All @@ -125,7 +125,7 @@ func (track *InitTrack) marshal(w *mp4Writer) error {
h264SPS = &h264.SPS{}
err = h264SPS.Unmarshal(codec.SPS)
if err != nil {
return fmt.Errorf("unable to parse H264 SPS: %v", err)
return fmt.Errorf("unable to parse H264 SPS: %w", err)
}

width = h264SPS.Width()
Expand Down
2 changes: 1 addition & 1 deletion pkg/formats/mpegts/opus_access_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type opusAccessUnit struct {
func (au *opusAccessUnit) unmarshal(buf []byte) (int, error) {
n, err := au.ControlHeader.unmarshal(buf)
if err != nil {
return 0, fmt.Errorf("could not decode control header: %v", err)
return 0, fmt.Errorf("could not decode control header: %w", err)
}
buf = buf[n:]

Expand Down
3 changes: 2 additions & 1 deletion pkg/formats/mpegts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mpegts

import (
"context"
"errors"
"fmt"
"io"

Expand Down Expand Up @@ -75,7 +76,7 @@ func NewReader(br io.Reader) (*Reader, error) {
var track Track
err := track.unmarshal(dem, es)
if err != nil {
if err == errUnsupportedCodec {
if errors.Is(err, errUnsupportedCodec) {
continue
}
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion pkg/formats/mpegts/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package mpegts
import (
"bytes"
"context"
"errors"
"testing"

"github.com/asticode/go-astits"
Expand Down Expand Up @@ -932,7 +933,7 @@ func TestReader(t *testing.T) {

for {
err := r.Read()
if err == astits.ErrNoMorePackets {
if errors.Is(err, astits.ErrNoMorePackets) {
break
}
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/formats/mpegts/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func findMPEG4AudioConfig(dem *astits.Demuxer, pid uint16) (*mpeg4audio.Config,
var adtsPkts mpeg4audio.ADTSPackets
err = adtsPkts.Unmarshal(data.PES.Data)
if err != nil {
return nil, fmt.Errorf("unable to decode ADTS: %s", err)
return nil, fmt.Errorf("unable to decode ADTS: %w", err)
}

pkt := adtsPkts[0]
Expand All @@ -57,13 +57,13 @@ func findAC3Parameters(dem *astits.Demuxer, pid uint16) (int, int, error) {
var syncInfo ac3.SyncInfo
err = syncInfo.Unmarshal(data.PES.Data)
if err != nil {
return 0, 0, fmt.Errorf("invalid AC-3 frame: %s", err)
return 0, 0, fmt.Errorf("invalid AC-3 frame: %w", err)
}

var bsi ac3.BSI
err = bsi.Unmarshal(data.PES.Data[5:])
if err != nil {
return 0, 0, fmt.Errorf("invalid AC-3 frame: %s", err)
return 0, 0, fmt.Errorf("invalid AC-3 frame: %w", err)
}

return syncInfo.SampleRate(), bsi.ChannelCount(), nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/formats/mpegts/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package mpegts
import (
"bytes"
"context"
"errors"
"testing"

"github.com/asticode/go-astits"
Expand Down Expand Up @@ -78,7 +79,7 @@ func TestWriter(t *testing.T) {

for {
pkt, err := dem.NextPacket()
if err == astits.ErrNoMorePackets {
if errors.Is(err, astits.ErrNoMorePackets) {
break
}
require.NoError(t, err)
Expand Down

0 comments on commit 3937359

Please sign in to comment.