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 / simple / testdata / src / CheckBytesBufferConversions / LintBytesBufferConversions.go
1 package pkg
2
3 import (
4         "bytes"
5 )
6
7 func fn() {
8         buf := bytes.NewBufferString("str")
9         _ = string(buf.Bytes())  // want `should use buf\.String\(\) instead of string\(buf\.Bytes\(\)\)`
10         _ = []byte(buf.String()) // want `should use buf\.Bytes\(\) instead of \[\]byte\(buf\.String\(\)\)`
11
12         m := map[string]*bytes.Buffer{"key": buf}
13         _ = string(m["key"].Bytes())  // want `should use m\["key"\]\.String\(\) instead of string\(m\["key"\]\.Bytes\(\)\)`
14         _ = []byte(m["key"].String()) // want `should use m\["key"\]\.Bytes\(\) instead of \[\]byte\(m\["key"\]\.String\(\)\)`
15
16         string := func(_ interface{}) interface{} {
17                 return nil
18         }
19         _ = string(m["key"].Bytes())
20 }