-
Couldn't load subscription status.
- Fork 18.4k
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.17.1 linux/amd64
Also reproduces on the playground (see below).
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/silex/.cache/go-build" GOENV="/home/silex/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/silex/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/silex/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib64/golang" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib64/golang/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.17.1" GCCGO="gccgo" AR="ar" CC="x86_64-solus-linux-gcc" CXX="x86_64-solus-linux-g++" CGO_ENABLED="1" GOMOD="/dev/null" 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-build858878585=/tmp/go-build -gno-record-gcc-switches"
What did you do?
When marshalling a struct with an interface field to an XML attribute, an error is returned. Simple example, extended example.
What did you expect to see?
No error, and for the simple example:
XML: <Test a="2009-11-10T23:00:00Z"></Test>
The extended example should return:
<Test a="hello" b="there"><a>hello</a><b>there</b></Test> (err: %!s(<nil>))
<ITest><a>hello</a><b>there</b></ITest> (err: %!s(<nil>))
<ITest a="hello" b="there"><a>hello</a><b>there</b></ITest> (err: %!s(<nil>))
What did you see instead?
Error: xml: unsupported type: time.Time
This error is incorrect (time.Time implements encoding.TextMarshaler), so should be supported.
Additionally, this does work with values instead of attributes, as shown in the extended example:
<Test a="hello" b="there"><a>hello</a><b>there</b></Test> (err: %!s(<nil>))
<ITest><a>hello</a><b>there</b></ITest> (err: %!s(<nil>))
(err: xml: unsupported type: main.A)
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.