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: Marshal ignores ",chardata" fields not of type []byte #4506

Closed
gopherbot opened this issue Dec 8, 2012 · 6 comments
Closed

encoding/xml: Marshal ignores ",chardata" fields not of type []byte #4506

gopherbot opened this issue Dec 8, 2012 · 6 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 8, 2012

by philipp.schumann:

"What steps will reproduce the problem? What is the expected output? What do you
see instead?"

A float64 tagged as chardata gets unmarshaled just fine with no issues, however
marshaling such a thing results in empty node values:

http://play.golang.org/p/gMsuECdiFe

I'd assume that Marshal() should closely match Unmarshal()'s capabilities. Admittedly
"round-tripping" use-cases are rare, but still...

"Which compiler are you using?"

6g

"Which operating system are you using?"

Windows 7

"Which version are you using?"

1.0.3
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 9, 2012

Comment 1:

In marshal.go:
        switch finfo.flags & fMode {
        case fCharData:
            switch vf.Kind() {
            case reflect.String:
                Escape(p, []byte(vf.String()))
            case reflect.Slice:
                if elem, ok := vf.Interface().([]byte); ok {
                    Escape(p, elem)
                }
            }
            continue
The switch needs to invert all the cases that read.go's copyValue does.

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-m.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 10, 2012

Comment 3:

Labels changed: added suggested.

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Jan 14, 2013

Comment 4 by vegacom:

I started working on this.
The missing field types are int, uint, float and bool:
http://tip.play.golang.org/p/pJbHVG5Fbq
@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Jan 14, 2013

Comment 5 by vegacom:

https://golang.org/cl/7106045/
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Jan 23, 2013

Comment 6:

This issue was closed by revision 14bd52d.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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
2 participants
You can’t perform that action at this time.