Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / staticcheck / testdata / src / checkStdlibUsageNilContext / checkStdlibUsageNilContext.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/checkStdlibUsageNilContext/checkStdlibUsageNilContext.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/checkStdlibUsageNilContext/checkStdlibUsageNilContext.go
new file mode 100644 (file)
index 0000000..451996f
--- /dev/null
@@ -0,0 +1,24 @@
+package pkg
+
+import "context"
+
+func fn1(ctx context.Context)           {}
+func fn2(x string, ctx context.Context) {}
+func fn4()                              {}
+
+type T struct{}
+
+func (*T) Foo() {}
+
+func fn3() {
+       fn1(nil) // want `do not pass a nil Context`
+       fn1(context.TODO())
+       fn2("", nil)
+       fn4()
+
+       // don't flag this conversion
+       _ = (func(context.Context))(nil)
+       // and don't crash on these
+       _ = (func())(nil)
+       (*T).Foo(nil)
+}