Created
July 30, 2014 17:45
-
-
Save lamp/bee404a57b12514c3e53 to your computer and use it in GitHub Desktop.
Reading a yaml file in go...maybe
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( | |
| "os" | |
| "log" | |
| "gopkg.in/yaml.v1" | |
| ) | |
| type T struct { | |
| A string | |
| B struct { C int; D []int ",flow"} | |
| } | |
| func main(){ | |
| config, err := os.Open("config.yml") | |
| if err != nil{ | |
| log.Fatal(err) | |
| } | |
| t := T{} | |
| f := make([]byte, 100) | |
| config.Read(f) | |
| error := yaml.Unmarshal([]byte(f), &t) | |
| if error != nil { | |
| log.Fatal(error) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment