Inspectopedia Help

'Unmarshal' is called with the incorrect argument

Reports calls to json.Unmarshal and similar functions if the argument that is passed to store the result is not a pointer or an interface.

These calls will fail and return an error.

For more information about Unmarshal, see func Unmarshal at go.dev.

Example:

var animals []Animal err := json.Unmarshal(jsonData, animals) // always returns an error

After the Prepend '&' quick-fix is applied:

var animals []Animal err := json.Unmarshal(jsonData, &animals)

Inspection Details

Available in:

GoLand 2023.3

Plugin:

Go, 233.SNAPSHOT

Last modified: 13 July 2023