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
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@gopherbot
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 3:

Labels changed: added suggested.

@gopherbot
Copy link
Author

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
Copy link
Author

Comment 5 by vegacom:

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

@rsc
Copy link
Contributor

rsc commented Jan 23, 2013

Comment 6:

This issue was closed by revision 14bd52d.

Status changed to Fixed.

@gopherbot gopherbot added fixed Suggested Issues that may be good for new contributors looking for work to do. labels Jan 23, 2013
@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.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

2 participants