github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/staticcheck/testdata/src/CheckEncodingBinary/CheckEncodingBinary.go (about) 1 package pkg 2 3 import ( 4 "encoding/binary" 5 "io/ioutil" 6 "log" 7 ) 8 9 func fn() { 10 type T1 struct { 11 A int32 12 } 13 type T2 struct { 14 A int32 15 B int 16 } 17 type T3 struct { 18 A []int32 19 } 20 type T4 struct { 21 A *int32 22 } 23 type T5 struct { 24 A int32 25 } 26 type T6 []byte 27 28 var x1 int 29 var x2 int32 30 var x3 []int 31 var x4 []int32 32 var x5 [1]int 33 var x6 [1]int32 34 var x7 T1 35 var x8 T2 36 var x9 T3 37 var x10 T4 38 var x11 = &T5{} 39 var x13 []byte 40 var x14 *[]byte 41 var x15 T6 42 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x1)) // MATCH /cannot be used with binary.Write/ 43 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x2)) 44 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x3)) // MATCH /cannot be used with binary.Write/ 45 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x4)) 46 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x5)) // MATCH /cannot be used with binary.Write/ 47 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x6)) 48 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x7)) 49 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x8)) // MATCH /cannot be used with binary.Write/ 50 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x9)) // MATCH /cannot be used with binary.Write/ 51 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x10)) // MATCH /cannot be used with binary.Write/ 52 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x11)) 53 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, &x13)) 54 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, &x14)) // MATCH /cannot be used with binary.Write/ 55 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x15)) 56 log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, &x15)) 57 }