github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckUnmarshalPointer.go (about)

     1  package pkg
     2  
     3  import "encoding/json"
     4  
     5  func fn1(i3 interface{}) {
     6  	var v map[string]interface{}
     7  	var i1 interface{} = v
     8  	var i2 interface{} = &v
     9  	p := &v
    10  	json.Unmarshal([]byte(`{}`), v) // MATCH /Unmarshal expects to unmarshal into a pointer/
    11  	json.Unmarshal([]byte(`{}`), &v)
    12  	json.Unmarshal([]byte(`{}`), i1) // MATCH /Unmarshal expects to unmarshal into a pointer/
    13  	json.Unmarshal([]byte(`{}`), i2)
    14  	json.Unmarshal([]byte(`{}`), i3)
    15  	json.Unmarshal([]byte(`{}`), p)
    16  
    17  	json.NewDecoder(nil).Decode(v) // MATCH /Decode expects to unmarshal into a pointer/
    18  }