Last active
December 18, 2015 14:28
-
-
Save deepakjois/5797150 to your computer and use it in GitHub Desktop.
Is there a bug in the YAML decoder?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"encoding/json" | |
"launchpad.net/goyaml" | |
) | |
type Bar struct { | |
Name string | |
} | |
type Foo struct { | |
Address string | |
Bar | |
} | |
func main() { | |
var g Foo | |
var h Bar | |
err := goyaml.Unmarshal([]byte("---\nname: Deepak"),&g) | |
fmt.Println(g) // Output: { {}} (Does not work) | |
fmt.Println(err) // <nil> | |
json.Unmarshal([]byte("{ \"Name\" : \"Deepak\" }"),&g) | |
fmt.Println(g) // Output: { {Deepak}} (Works) | |
goyaml.Unmarshal([]byte("---\nname: Deepak"),&h) | |
fmt.Println(h) // Output: {Deepak} (Works) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment