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/xml: Unmarshal improper behavior with non-string types and empty tags #21503

Closed
LeonineKing1199 opened this Issue Aug 17, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@LeonineKing1199
Copy link

LeonineKing1199 commented Aug 17, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.3 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/exbigboss/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f2/331cyngd4nxb24p47_sb9zx40000gn/T/go-build190222818=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

https://play.golang.org/p/3y8tab_Ipn

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

I expected that Value would default to false (the zero value for the type)

What did you see instead?

I received a parsing error

@ianlancetaylor ianlancetaylor changed the title XML Unmarshal improper behavior with non-string types and empty tags encoding/xml: Unmarshal improper behavior with non-string types and empty tags Aug 17, 2017

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Aug 17, 2017

@namusyaka

This comment has been minimized.

Copy link
Member

namusyaka commented Aug 19, 2017

This was fixed by 0a0186f, I think.

@LeonineKing1199 Could you confirm that?

@LeonineKing1199

This comment has been minimized.

Copy link
Author

LeonineKing1199 commented Aug 19, 2017

I think I'm just using outdated versions of Go then. I checked the git commit you posted and it looks like it was intended for Go 1.9. I'm using 1.8 on both my Mac and Windows machines and it's equally broken in both places.

I circumvented the issue by creating a quick little nilable package.

@ALTree

This comment has been minimized.

Copy link
Member

ALTree commented Aug 19, 2017

go1.9rc2 output is &{Value:false Name:Big Boss}, so it appears that this is fixed.

Closing this issue, since there's noting more to do.

@ALTree ALTree closed this Aug 19, 2017

@LeonineKing1199

This comment has been minimized.

Copy link
Author

LeonineKing1199 commented Aug 20, 2017

I know the issue is closed but could the docs be updated until the stable release is 1.9?

It'd be useful if the docs also contained that information for the sake of legacy code. How about something like this,

Pre-1.9 unmarshaling will return a parsing error in the case of empty tags for non-string unmarshalling targets.

For example:
/ * code sample goes here /*

will return the error:  sample error

Go 1.9 and beyond will instead assign use the default constructor. Er, I mean zero value.
@ALTree

This comment has been minimized.

Copy link
Member

ALTree commented Aug 20, 2017

I know the issue is closed but could the docs be updated until the stable release is 1.9

go1.9 should be released in a few days, so I don't think it's worth it.

Also updating the go1.8 website would require the release of a new minor (1.8.4), and there's almost no chance of that happening, since the website will be re-deployed for go1.9 very soon (and this issue won't be there, since it was fixed for go1.9).

@golang golang locked and limited conversation to collaborators Aug 20, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.