From 363bd8a7f933a512079a7af5c3614a0bed83f321 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 1 Mar 2024 18:50:26 +0000 Subject: [PATCH] chore: enable Go linting and vetting + rename CI job (#11) * chore: enable Go linting and vetting + rename job * chore: use `golangci/golangci-lint-action` * fix: placate the linter --- .github/workflows/go.yml | 16 ++++++++++++---- compile.go | 6 +++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6577718..603dec4 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,13 +12,13 @@ on: jobs: - build: + go: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 + - name: Setup + uses: actions/setup-go@v5 with: go-version: '1.20' @@ -27,3 +27,11 @@ jobs: - name: Test run: go test -v ./... + + - name: Lint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.54 + + - name: Vet + run: go vet ./... diff --git a/compile.go b/compile.go index 1dcdf6f..aaf95e4 100644 --- a/compile.go +++ b/compile.go @@ -275,7 +275,11 @@ func (s *spliceConcat) shrink() error { func (s *spliceConcat) bytes() ([]byte, error) { code := new(bytes.Buffer) for _, sp := range s.all { - sp.buf.WriteTo(code) + if _, err := sp.buf.WriteTo(code); err != nil { + // This should be impossible, but ignoring the error angers the + // linter. + return nil, fmt.Errorf("%T.bytes(): %T.buf.WriteTo(%T): %v", s, sp, code, err) + } switch sp.op.(type) { case JUMPDEST: