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

$ go version
go version go1.14.1 windows/amd64

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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Constantine\AppData\Local\go-build
set GOENV=C:\Users\Constantine\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\Develop\golib
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\Develop\go1.14.1
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Develop\go1.14.1\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\CONSTA~1\AppData\Local\Temp\go-build125187114=/tmp/go-build -gno-record-gcc-switches

What did you do?

Try to use XMLName in embedded type play stackoverflow

type XMLForm struct {
    XMLName xml.Name
}
type Test struct {
    XMLForm
}
var t Test
t.XMLName.Local = "c:test"

xml.Marshal(&t)

What did you expect to see?

<c:test></c:test>

What did you see instead?

<Test></Test>

It fails on go1.14.1\src\encoding\xml\marshal.go: can't cast to xml.Name

482: } else if v, ok := xmlname.value(val).Interface().(Name); ok && v.Local != "" {
483:       start.Name = v
484: }

I also find a reason for this error https://golang.org/src/encoding/xml/typeinfo.go Need to add idx of embed type to slice

78:   if tinfo.xmlname == nil {
++                                        && inner.xmlname != nil {
79:      tinfo.xmlname = inner.xmlname
++      tinfo.xmlname.idx = append([]int{i}, inner.xmlname.idx...)
80:   }

Comment From: seankhliao

This works now

Comment From: lunicon

This works now

Try play for go.dev - same result

Comment From: RangelReale

Also the same happens for Unmarshal, the XMLName if blank if it is on the anonymous struct. If I move it to the root struct, then it works.