github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckWriterBufferModified.go (about) 1 package pkg 2 3 type T1 struct{} 4 type T2 struct{} 5 type T3 struct{} 6 type T4 struct{} 7 8 func (T1) Write(b []byte) (int, error) { 9 b = append(b, '\n') // MATCH /io.Writer.Write must not modify the provided buffer/ 10 _ = b 11 return 0, nil 12 } 13 14 func (T2) Write(b []byte) (int, error) { 15 b[0] = 0 // MATCH /io.Writer.Write must not modify the provided buffer/ 16 return 0, nil 17 } 18 19 func (T3) Write(b []byte) string { 20 b[0] = 0 21 return "" 22 } 23 24 func (T4) Write(b []byte, r byte) (int, error) { 25 b[0] = r 26 return 0, nil 27 }