diff --git a/.golangci.yml b/.golangci.yml index c5a183c..3669242 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,7 +12,6 @@ linters: # These are all considered deprecated: https://github.com/golangci/golangci-lint/issues/1841 - deadcode - structcheck - - unused - varcheck linters-settings: exhaustive: diff --git a/fail.go b/fail.go new file mode 100644 index 0000000..bb37bf6 --- /dev/null +++ b/fail.go @@ -0,0 +1,17 @@ +package wsrpc + +import ( + "errors" + "os" + "testing" +) + +func FailLintOutOfTestFile(t *testing.T) { + const UnusedVar = 1 // lint should complain for unused variable + const ALL_CAPS = 10 // should be camel cased + err := os.ErrNotExist + if err == os.ErrNotExist { // should use errors.Is + err := errors.New("fake error") // shadowed variable + t.Log(err) + } +} diff --git a/fail_test.go b/fail_test.go new file mode 100644 index 0000000..211e42c --- /dev/null +++ b/fail_test.go @@ -0,0 +1,39 @@ +package wsrpc + +import ( + "errors" + "os" + "sync" + "testing" +) + +// func TestFail(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } +// t.Fatal("fake failure") +// } + +func TestRace(t *testing.T) { + var v int + var wg sync.WaitGroup + wg.Add(100) + for i := 0; i < 100; i++ { + go func() { + defer wg.Done() + v++ + v-- + }() + } + wg.Wait() + t.Log(v) +} + +func TestLint(t *testing.T) { + const ALL_CAPS = 10 // should be AllCaps + err := os.ErrNotExist + if err == os.ErrNotExist { // should use errors.Is + err := errors.New("fake error") // shadowed variable + t.Log(err) + } +}