Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / staticcheck / testdata / src / CheckWriterBufferModified / CheckWriterBufferModified.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/CheckWriterBufferModified/CheckWriterBufferModified.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.5/staticcheck/testdata/src/CheckWriterBufferModified/CheckWriterBufferModified.go
new file mode 100644 (file)
index 0000000..dc31670
--- /dev/null
@@ -0,0 +1,27 @@
+package pkg
+
+type T1 struct{}
+type T2 struct{}
+type T3 struct{}
+type T4 struct{}
+
+func (T1) Write(b []byte) (int, error) {
+       b = append(b, '\n') // want `io\.Writer\.Write must not modify the provided buffer`
+       _ = b
+       return 0, nil
+}
+
+func (T2) Write(b []byte) (int, error) {
+       b[0] = 0 // want `io\.Writer\.Write must not modify the provided buffer`
+       return 0, nil
+}
+
+func (T3) Write(b []byte) string {
+       b[0] = 0
+       return ""
+}
+
+func (T4) Write(b []byte, r byte) (int, error) {
+       b[0] = r
+       return 0, nil
+}