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

Marshal produces output that Unmarshal cannot decode #24

Closed
rogpeppe opened this issue Aug 14, 2014 · 1 comment
Closed

Marshal produces output that Unmarshal cannot decode #24

rogpeppe opened this issue Aug 14, 2014 · 1 comment

Comments

@rogpeppe
Copy link
Contributor

After commit 72c33f6, this code fails.
Even if the yaml package was changed to quote "<" on output, we'd
still have a problem, as this character has not been quoted historically,
so it can fail to parse old files (or output produced by other yaml producers,
such as python's yaml module).

package main

import (
    "log"
    "fmt"
    "gopkg.in/yaml.v1"
)

func main() {
    d := struct {
        Net string
    }{
        `<foo>=bar`,
    }
    data, err := yaml.Marshal(d)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s", data)
    var x interface{}
    err = yaml.Unmarshal(data, &x)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%#v", x)
}
niemeyer added a commit that referenced this issue Aug 14, 2014
@rogpeppe
Copy link
Contributor Author

Fixed by feb4ca7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant