gopkg.in/golangci/golangci-lint.v1@v1.10.1/test/testdata/errcheck.go (about) 1 // args: -Eerrcheck 2 package testdata 3 4 import ( 5 "bytes" 6 "net/http" 7 "os" 8 ) 9 10 func RetErr() error { 11 return nil 12 } 13 14 func MissedErrorCheck() { 15 RetErr() // ERROR "Error return value of `RetErr` is not checked" 16 } 17 18 func IgnoreCloseMissingErrHandling() error { 19 f, err := os.Open("t.go") 20 if err != nil { 21 return err 22 } 23 24 f.Close() 25 return nil 26 } 27 28 func IgnoreCloseInDeferMissingErrHandling() { 29 resp, err := http.Get("http://example.com/") 30 if err != nil { 31 panic(err) 32 } 33 defer resp.Body.Close() 34 35 panic(resp) 36 } 37 38 func IgnoreStdxWrite() { 39 os.Stdout.Write([]byte{}) 40 os.Stderr.Write([]byte{}) 41 } 42 43 func IgnoreBufferWrites(buf *bytes.Buffer) { 44 buf.WriteString("x") 45 }