package pkg

import (
	"bytes"
)

func fn() {
	buf := bytes.NewBufferString("str")
	_ = buf.String() //@ diag(`should use buf.String() instead of string(buf.Bytes())`)
	_ = buf.Bytes()  //@ diag(`should use buf.Bytes() instead of []byte(buf.String())`)

	m := map[string]*bytes.Buffer{"key": buf}
	_ = m["key"].String() //@ diag(`should use m["key"].String() instead of string(m["key"].Bytes())`)
	_ = m["key"].Bytes()  //@ diag(`should use m["key"].Bytes() instead of []byte(m["key"].String())`)

	var m2 map[string]int
	_ = m2[string(buf.Bytes())] // no warning, this is more efficient than buf.String()

	string := func(_ interface{}) interface{} {
		return nil
	}
	_ = string(m["key"].Bytes())
}
