github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckIneffectiveAppend.go (about) 1 package pkg 2 3 import "fmt" 4 5 func fn1() { 6 var s []int 7 s = append(s, 1) // MATCH /this result of append is never used/ 8 // MATCH:9 /this value of s is never used/ 9 s = append(s, 1) // MATCH /this result of append is never used/ 10 } 11 12 func fn2() (named []int) { 13 named = append(named, 1) 14 return 15 } 16 17 func fn3() { 18 s := make([]int, 0) 19 // MATCH:20 /this value of s is never used/ 20 s = append(s, 1) // MATCH /this result of append is never used/ 21 } 22 23 func fn4() []int { 24 var s []int 25 s = append(s, 1) 26 return s 27 } 28 29 func fn5() { 30 var s []int 31 s = append(s, 1) 32 fn6(s) 33 } 34 35 func fn6([]int) {} 36 37 func fn7() { 38 var s []int 39 fn8(&s) 40 s = append(s, 1) 41 } 42 43 func fn8(*[]int) {} 44 45 func fn9() { 46 var s []int 47 s = append(s, 1) 48 fmt.Println(s) 49 // MATCH:50 /this value of s is never used/ 50 s = append(s, 1) // MATCH /this result of append is never used/ 51 } 52 53 func fn10() { 54 var s []int 55 return 56 s = append(s, 1) 57 } 58 59 func fn11() { 60 var s []int 61 for x := 0; x < 10; x++ { 62 s = append(s, 1) // MATCH /this result of append is never used/ 63 } 64 }