Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/json: empty fields in json.UnmarshalTypeError when using struct with UnmarshalJSON #28076

Closed
Keylor42 opened this issue Oct 8, 2018 · 2 comments

Comments

@Keylor42
Copy link

@Keylor42 Keylor42 commented Oct 8, 2018

What version of Go are you using (go version)?

go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""`
GOCACHE="/home/tpaulmyer/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tpaulmyer/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build650471952=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I tried to unmarshal a wrong type into a struct that has a custom UnmarshalJSON method attached to it and use the fields of the UnmarshalTypeError: https://play.golang.org/p/nNQ2v76VZnz.

What did you expect to see?

In go 1.10.4, the fields Struct and Field of the UnmarshalTypeError are set.

What did you see instead?

In go 1.11.1, they are not.

@iand

This comment has been minimized.

Copy link
Contributor

@iand iand commented Oct 9, 2018

Duplicate of #27464 which is fixed on tip

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Oct 9, 2018

Thanks.

@agnivade agnivade closed this Oct 9, 2018
@golang golang locked and limited conversation to collaborators Oct 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.