diff --git a/.golangci.yml b/.golangci.yml index eb4fccd..2d398cb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,8 @@ run: # Timeout for analysis, e.g. 30s, 5m. # Default: 1m timeout: 3m + build-tags: + - example # This file contains only configs which differ from defaults. # All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml @@ -274,5 +276,8 @@ issues: # specific to pt - path: "_test\\.go" - linters: - - gocognit + linters: [ gocognit ] + - path: "example_test\\.go" + linters: [ testpackage ] + - path: "example\\.go" + linters: [ gomnd ] diff --git a/example/example.go b/example/example.go index fbd1ffc..0e4059e 100644 --- a/example/example.go +++ b/example/example.go @@ -1,13 +1,14 @@ +//go:build example // +build example package example func sum(numbers ...int) int { - sum := 0 + s := 0 for _, n := range numbers { - sum += n + s += n } - return sum + return s } func fibonacci(n uint64) uint64 { diff --git a/example/example_test.go b/example/example_test.go index 40a7f08..fec9997 100644 --- a/example/example_test.go +++ b/example/example_test.go @@ -1,3 +1,4 @@ +//go:build example // +build example package example diff --git a/pt.go b/pt.go index f3dbbca..7cf9bdd 100644 --- a/pt.go +++ b/pt.go @@ -187,8 +187,7 @@ func Test(name string, test func(t *testing.T)) testing.InternalTest { // alreadyParallel returns value of private field isParallel for provided t *testing.T. func alreadyParallel(t *testing.T) bool { - // copy of mutex is not used, so can ignore govet error - testObject := reflect.ValueOf(*t) //nolint:govet // here it's ok to copy lock value + testObject := reflect.ValueOf(t).Elem() isParallelField := testObject.FieldByName("isParallel") isParallel := isParallelField.Bool() return isParallel