Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

jobs:

Expand All @@ -32,9 +33,9 @@ jobs:
run: make gen git/diff

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: latest
version: v2.1
args: ./... ./internal/cmd/generate/...

- run: go install github.com/google/addlicense@latest
Expand Down
42 changes: 22 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
version: "2"
linters:
# Defaults, plus:
enable:
- errname
- errorlint
- exportloopref
- gocritic
- godot
- goheader
- goimports
- gosec
- lll
- makezero
- misspell
- nilerr
- nilnil
- nolintlint
- prealloc
- revive
- unconvert
- unparam
- whitespace
- errname
- errorlint
- gocritic
- godot
- goheader
- gosec
- lll
- makezero
- misspell
- nilerr
- nilnil
- nolintlint
- prealloc
- revive
- unconvert
- unparam
- whitespace

formatters:
enable:
- goimports
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ ADDLICENSE_FLAGS ?= -c 'Alan Parra' -l mit -ignore '**/*.yml'
.PHONY: all
all: build

# ci partly mimics CI checks.
# Does not run `fix` or `gen` targets to avoid dirtying the local workspace.
.PHONY: ci
ci: build test lint

.PHONY: clean
clean:
rm -f cover.out generate
Expand Down
3 changes: 2 additions & 1 deletion gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

//go:generate go run ./internal/cmd/generate -o semerr.gen.go
package semerr

//go:generate go run ./internal/cmd/generate -o semerr.gen.go
1 change: 1 addition & 0 deletions internal/cmd/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func run() error {
out = os.Stdout
} else {
var err error
//nolint:gosec // File permissions are fine at 644.
out, err = os.OpenFile(*outFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return err
Expand Down
13 changes: 6 additions & 7 deletions semerr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ import (
func TestFrom_unmapped(t *testing.T) {
err1 := errors.New("an error")

fromCode := func(n interface{}, err error) error {
c := semerr.Code(n.(int))
fromCode := func(n int, err error) error {
//nolint:gosec // Interger overflow is not a problem here.
c := semerr.Code(n)
return semerr.FromGRPCCode(c, err)
}
fromHTTP := func(s interface{}, err error) error {
return semerr.FromHTTPStatus(s.(int), err)
}
fromHTTP := semerr.FromHTTPStatus

tests := []struct {
name string
fn func(interface{}, error) error
in interface{}
fn func(int, error) error
in int
}{
{
name: "FromGRPCCode(OK, $err)",
Expand Down
Loading