diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81409f2..3b17429 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,5 +13,7 @@ jobs: - uses: actions/setup-go@v2 with: go-version: '^1.16' + - run: make install-tools - run: make - run: make check COVERAGE=1 + - run: make lint diff --git a/Makefile b/Makefile index 4689ddc..d459861 100644 --- a/Makefile +++ b/Makefile @@ -25,9 +25,14 @@ ifeq ($(COVERAGE),1) go tool cover -html=coverage.out endif +.PHONY: install-tools +install-tools: + go install honnef.co/go/tools/cmd/staticcheck@2023.1.3 + +.PHONY: lint lint: - staticcheck . - go vet . + go vet ./... + staticcheck ./... example-live+junk.mkv: ffmpeg -t 1 -s 320x240 -f rawvideo -r 25 -pix_fmt rgb24 -i /dev/zero -metadata title="Live + Junk" -metadata author="John Doe" -c:v libx264 -pix_fmt yuv420p dirty.$@ diff --git a/examples/mkvinfo/mkvinfo.go b/examples/mkvinfo/mkvinfo.go index 67e5ea4..e029ac6 100644 --- a/examples/mkvinfo/mkvinfo.go +++ b/examples/mkvinfo/mkvinfo.go @@ -11,20 +11,10 @@ import ( ) type MyParser struct { - sawCluster bool } func (p *MyParser) HandleMasterBegin(id mkvparse.ElementID, info mkvparse.ElementInfo) (bool, error) { switch id { - case mkvparse.CuesElement: - fmt.Printf("%s- %s: \n", indent(info.Level), mkvparse.NameForElementID(id)) - return false, nil - case mkvparse.ClusterElement: - if !p.sawCluster { - p.sawCluster = true - fmt.Printf("%s- %s: \n", indent(info.Level), mkvparse.NameForElementID(id)) - } - return false, nil default: fmt.Printf("%s- %s:\n", indent(info.Level), mkvparse.NameForElementID(id)) return true, nil @@ -60,7 +50,7 @@ func (p *MyParser) HandleBinary(id mkvparse.ElementID, value []byte, info mkvpar case mkvparse.SeekIDElement: fmt.Printf("%s- %v: %x\n", indent(info.Level), mkvparse.NameForElementID(id), value) default: - fmt.Printf("%s- %v: \n", indent(info.Level), mkvparse.NameForElementID(id)) + fmt.Printf("%s- %v: (%d)\n", indent(info.Level), mkvparse.NameForElementID(id), info.Size) } return nil } diff --git a/internal/generate/generate.go b/internal/generate/generate.go index a20204a..15647d7 100644 --- a/internal/generate/generate.go +++ b/internal/generate/generate.go @@ -6,7 +6,6 @@ import ( "fmt" "go/format" "io" - "io/ioutil" "log" "net/http" "os" @@ -76,7 +75,7 @@ func generateElements() error { return err } defer sb.Close() - data, err := ioutil.ReadAll(sb) + data, err := io.ReadAll(sb) if err != nil { return err } @@ -296,8 +295,11 @@ type TagRegistry struct { func generateTags() error { sb, err := loadSchema("https://raw.githubusercontent.com/ietf-wg-cellar/matroska-specification/master/matroska_tags.xml") + if err != nil { + return err + } defer sb.Close() - data, err := ioutil.ReadAll(sb) + data, err := io.ReadAll(sb) // data, err := ioutil.ReadFile("specdata.xml") if err != nil { return err