.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.1.1 / staticcheck / testdata / src / CheckTypedNilInterface / i26000 / 26000.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.1.1/staticcheck/testdata/src/CheckTypedNilInterface/i26000/26000.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.1.1/staticcheck/testdata/src/CheckTypedNilInterface/i26000/26000.go
new file mode 100644 (file)
index 0000000..a086f8e
--- /dev/null
@@ -0,0 +1,34 @@
+package main
+
+import (
+       "fmt"
+       "os"
+)
+
+type CustomError struct {
+       Err string
+}
+
+func (ce CustomError) Error() string {
+       return ce.Err
+}
+
+func SomeFunc() (string, *CustomError) {
+       return "hello", nil
+}
+
+func main() {
+       // Do something that creates a variable err of type error
+       _, err := os.Open("/")
+       if err != nil {
+               panic(err)
+       }
+
+       // Then replace the err type with *CustomError
+       val, err := SomeFunc()
+       if err != nil { // want `this comparison is always true`
+               panic(err)
+       }
+
+       fmt.Println("No problem", val)
+}