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 / CheckPureFunctions / CheckPureFunctions.go
1 package pkg
2
3 import (
4         "context"
5         "net/http"
6         "strings"
7 )
8
9 func fn1() {
10         strings.Replace("", "", "", 1) // want `is a pure function but its return value is ignored`
11         foo(1, 2)                      // want `is a pure function but its return value is ignored`
12         baz(1, 2)                      // want `is a pure function but its return value is ignored`
13         _, x := baz(1, 2)
14         _ = x
15         bar(1, 2)
16 }
17
18 func fn2() {
19         r, _ := http.NewRequest("GET", "/", nil)
20         r.WithContext(context.Background()) // want `is a pure function but its return value is ignored`
21 }
22
23 func foo(a, b int) int        { return a + b }
24 func baz(a, b int) (int, int) { return a + b, a + b }
25 func bar(a, b int) int {
26         println(a + b)
27         return a + b
28 }
29
30 func empty()            {}
31 func stubPointer() *int { return nil }
32 func stubInt() int      { return 0 }
33
34 func fn3() {
35         empty()
36         stubPointer()
37         stubInt()
38 }