diff --git a/.golangci.yml b/.golangci.yml index 1c88a7110..45248de16 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,6 +6,7 @@ linters: - bidichk - gofmt - goimports + - govet - misspell - revive @@ -35,6 +36,48 @@ linters-settings: goimports: + govet: + # Matches what we use in corp as of 2023-12-07 + enable: + - asmdecl + - assign + - atomic + - bools + - buildtag + - cgocall + - copylocks + - deepequalerrors + - errorsas + - framepointer + - httpresponse + - ifaceassert + - loopclosure + - lostcancel + - nilfunc + - nilness + - printf + - reflectvaluecompare + - shift + - sigchanyzer + - sortslice + - stdmethods + - stringintconv + - structtag + - testinggoroutine + - tests + - unmarshal + - unreachable + - unsafeptr + - unusedresult + settings: + printf: + # List of print function names to check (in addition to default) + funcs: + - github.com/tailscale/tailscale/types/logger.Discard + # NOTE(andrew-d): this doesn't currently work because the printf + # analyzer doesn't support type declarations + #- github.com/tailscale/tailscale/types/logger.Logf + misspell: revive: diff --git a/Makefile b/Makefile index 166fa1948..8149ca1d9 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ vet: ## Run go vet tidy: ## Run go mod tidy ./tool/go mod tidy +lint: ## Run golangci-lint + ./tool/go run github.com/golangci/golangci-lint/cmd/golangci-lint run + updatedeps: ## Update depaware deps # depaware (via x/tools/go/packages) shells back to "go", so make sure the "go" # it finds in its $$PATH is the right one. diff --git a/cmd/tailscale/cli/cli_test.go b/cmd/tailscale/cli/cli_test.go index 4584af687..c1fe9b70a 100644 --- a/cmd/tailscale/cli/cli_test.go +++ b/cmd/tailscale/cli/cli_test.go @@ -1328,7 +1328,9 @@ func TestParseNLArgs(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { keys, disablements, err := parseNLArgs(tc.input, tc.parseKeys, tc.parseDisablements) - if !reflect.DeepEqual(err, tc.wantErr) { + if (tc.wantErr == nil && err != nil) || + (tc.wantErr != nil && err == nil) || + (tc.wantErr != nil && err != nil && tc.wantErr.Error() != err.Error()) { t.Fatalf("parseNLArgs(%v).err = %v, want %v", tc.input, err, tc.wantErr) } diff --git a/posture/serialnumber_macos_test.go b/posture/serialnumber_macos_test.go index 4ca22edf3..9f0ce1c6a 100644 --- a/posture/serialnumber_macos_test.go +++ b/posture/serialnumber_macos_test.go @@ -15,7 +15,7 @@ import ( func TestGetSerialNumberMac(t *testing.T) { // Do not run this test on CI, it can only be ran on macOS - // and we currenty only use Linux runners. + // and we currently only use Linux runners. if cibuild.On() { t.Skip() }