github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/staticcheck/testdata/src/CheckPureFunctions/CheckPureFunctions.go (about) 1 package pkg 2 3 import ( 4 "context" 5 "net/http" 6 "strings" 7 ) 8 9 func fn1() { 10 strings.Replace("", "", "", 1) // MATCH /is a pure function but its return value is ignored/ 11 foo(1, 2) // MATCH /is a pure function but its return value is ignored/ 12 bar(1, 2) 13 } 14 15 func fn2() { 16 r, _ := http.NewRequest("GET", "/", nil) 17 r.WithContext(context.Background()) // MATCH /is a pure function but its return value is ignored/ 18 } 19 20 func foo(a, b int) int { return a + b } 21 func bar(a, b int) int { 22 println(a + b) 23 return a + b 24 } 25 26 func empty() {} 27 func stubPointer() *int { return nil } 28 func stubInt() int { return 0 } 29 30 func fn3() { 31 empty() 32 stubPointer() 33 stubInt() 34 }