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, encoding/json: package docs don't mention encoding.TextMarshaler and encoding.TextUnmarshaler #6859

Closed
songgao opened this issue Dec 1, 2013 · 6 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@songgao
Copy link

songgao commented Dec 1, 2013

version: Go 1.2

What is the expected output?
`encoding/xml` and `encoding/json` should document the behavior that it will check
encoding.TextMarshaler and encoding.TextUnmarshaler.
@dsymonds
Copy link
Contributor

dsymonds commented Dec 2, 2013

Comment 1:

Labels changed: added priority-soon, documentation, size-s, removed priority-triage.

Owner changed to @rsc.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 2:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 3:

Labels changed: added repo-main.

@AlekSi
Copy link
Contributor

AlekSi commented Jul 6, 2015

I wanted some text format for for my struct so I implemented TextMarshaler and TextUnmarshaler like this:

func (t *T) MarshalText() ([]byte, error) {
    return xml.MarshalIndent(m, "", "  ")
}

func (t *T) UnmarshalText(b []byte) error {
    return xml.Unmarshal(b, m)
}

Then I spent an hour debugging why simplest code like t.UnmarshalText(bytes) fails with io.EOF.

Please document this behaviour.

@ALTree ALTree modified the milestones: Go1.10, Unplanned Jul 25, 2017
@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 25, 2017
@gopherbot
Copy link

Change https://golang.org/cl/76350 mentions this issue: encoding/xml,encoding/json: docs and examples using custom marshalers

@leighmcculloch
Copy link
Contributor

CL 76350 contains:

  • Examples for both encoding/json and encoding/xml that demonstrate using the encoding.TextMarshaler and encoding.TextUnmarshaler interfaces.
  • An example for encoding/xml that demonstrates custom marshaling using MarshalXML and UnmarshalXML.
  • Docs for encoding/xml that are mirrored off encoding/json.

All new examples are modeled off the existing custom marshal example in encoding/json.

@rsc rsc modified the milestones: Go1.10, Go1.11 Dec 1, 2017
@bradfitz bradfitz modified the milestones: Go1.11, Go1.12 Jun 13, 2018
@ianlancetaylor ianlancetaylor modified the milestones: Go1.12, Go1.13 Dec 11, 2018
@golang golang locked and limited conversation to collaborators Dec 12, 2019
@rsc rsc removed their assignment Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

9 participants