<p dir="auto">When un-marshaling, go json decode does not report the context ( field name or path to the element) that has a type error. On large files this can be a problem. If you have nested objects it might be harder to find so ideally a stack of keys that form a path would be described if possible.</p>
<p dir="auto">See stack overflow questions<br>
<a href="http://stackoverflow.com/questions/24325210/get-field-name-that-errs-in-go-json-unmarshal" rel="nofollow">http://stackoverflow.com/questions/24325210/get-field-name-that-errs-in-go-json-unmarshal</a><br>
<a href="http://stackoverflow.com/questions/21151765/json-cannot-unmarshal-string-into-go-value-of-type-int64" rel="nofollow">http://stackoverflow.com/questions/21151765/json-cannot-unmarshal-string-into-go-value-of-type-int64</a><br>
<a href="http://stackoverflow.com/questions/23582744/go-get-a-broken-json-field-name" rel="nofollow">http://stackoverflow.com/questions/23582744/go-get-a-broken-json-field-name</a></p>
<p dir="auto">Originally described in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="60653241" data-permission-text="Title is private" data-url="https://github.com/golang/go/issues/10134" data-hovercard-type="issue" data-hovercard-url="/golang/go/issues/10134/hovercard" href="https://github.com/golang/go/issues/10134">#10134</a> I have a possible solution there.</p>
<pre class="notranslate">&gt; What steps will reproduce the problem?

// test.go
package main
import (
    "flag"
    "fmt"
    "rand"
    "runtime"
    "sort"
)
func main() {
    fmt.Printf("Hello, World!")
}

$go build test.go

&gt; What is the expected output?
The tool either successfully compiles the program or produces a meaningful error message.

&gt; What do you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x455f80]

goroutine 1 [running]:
runtime.panic(0x669e68, 0xf8401ce7b0)
    /usr/local/google/home/dvyukov/go_select/src/pkg/runtime/proc.c:1406 +0xac
runtime.panicstring(0x82dcb3, 0xf840002570)
    /usr/local/google/home/dvyukov/go_select/src/pkg/runtime/runtime.c:128 +0xa3
runtime.sigpanic()
    /usr/local/google/home/dvyukov/go_select/src/pkg/runtime/thread_linux.c:198 +0x168
go/build.(*Tree).PkgDir(0x0, 0xf8400432c0, 0x0, 0xf8401ad1c0)
    /usr/local/google/home/dvyukov/go_select/src/pkg/go/build/path.go:52 +0xfb
main.(*builder).action(0xf840047000, 0x0, 0xf8401ad1c0, 0x1, 0xf8401ce7a0, ...)
    /usr/local/google/home/dvyukov/go_select/src/cmd/go/build.go:327 +0xb8
main.(*builder).action(0xf840047000, 0x1, 0xf84001ce00, 0x6e69616d00000002,
0xf8401e8b0a, ...)
    /usr/local/google/home/dvyukov/go_select/src/cmd/go/build.go:335 +0x208
main.runBuild(0x82abc0, 0xf840002020, 0x100000001, 0x0)
    /usr/local/google/home/dvyukov/go_select/src/cmd/go/build.go:129 +0x386
main.main()
    /usr/local/google/home/dvyukov/go_select/src/cmd/go/main.go:126 +0x2d8
runtime.main()
    /usr/local/google/home/dvyukov/go_select/src/pkg/runtime/proc.c:231 +0x45
runtime.goexit()
    /usr/local/google/home/dvyukov/go_select/src/pkg/runtime/proc.c:258

&gt;Please use labels and text to provide additional information.
11662:b6e94b31350e tip</pre>