Debian Codegraph @

staticcheck/sa1023/testdata/go1.0/CheckWriterBufferModified/CheckWriterBufferModified.go

raw
1 package pkg
2
3 type T1 struct{}
4 type T2 struct{}
5 type T3 struct{}
6 type T4 struct{}
7 type T5 struct{}
8 type T6 struct{}
9 type T7 struct{}
10
11 type Bytes []byte
12
13 func (T1) Write(b []byte) (int, error) {
14 b = append(b, '\n') //@ diag(`io.Writer.Write must not modify the provided buffer`)
15 _ = b
16 return 0, nil
17 }
18
19 func (T2) Write(b []byte) (int, error) {
20 b[0] = 0 //@ diag(`io.Writer.Write must not modify the provided buffer`)
21 return 0, nil
22 }
23
24 func (T3) Write(b []byte) string {
25 b[0] = 0
26 return ""
27 }
28
29 func (T4) Write(b []byte, r byte) (int, error) {
30 b[0] = r
31 return 0, nil
32 }
33
34 func (T7) Write(b Bytes) (int, error) {
35 b[0] = 0
36 return 0, nil
37 }