github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa1023/testdata/src/example.com/CheckWriterBufferModified/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') //@ diag(`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 //@ diag(`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  }