honnef.co/go/tools@v0.4.7/staticcheck/testdata/src/example.com/CheckMapBytesKey/key.go (about)

     1  package pkg
     2  
     3  func fn() {
     4  	var m map[string]int
     5  	var b []byte
     6  	_ = m[string(b)]
     7  	_ = m[string(b)]
     8  	s1 := string(b) //@ diag(`m[string(key)] would be more efficient than k := string(key); m[k]`)
     9  	_ = m[s1]
    10  	_ = m[s1]
    11  
    12  	s2 := string(b)
    13  	_ = m[s2]
    14  	_ = m[s2]
    15  	println(s2)
    16  }