Created
March 21, 2020 06:53
-
-
Save prashantv/fa4f92b4b95f936d68495be250ed3506 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
"prashant" |
This file contains hidden or 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" | |
"log" | |
"gopkg.in/yaml.v2" | |
) | |
type S struct { | |
Name string `yaml:"name"` | |
NamePointer *string `yaml:"namePtr"` | |
} | |
func main() { | |
s := &S{} | |
s.NamePointer = &s.Name | |
contents := ` | |
namePtr: "prashant" | |
` | |
if err := yaml.Unmarshal([]byte(contents), &s); err != nil { | |
log.Fatal(err) | |
} | |
fmt.Printf("%v\n", s.Name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment