Created
February 23, 2014 07:42
-
-
Save masahide/9168362 to your computer and use it in GitHub Desktop.
go でmapや配列等を pretty print (var_dumpみたいな何か)と yaml の読み込み ref: http://qiita.com/yamasaki-masahide/items/327ad9c423de1e35215f
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
mail_from: masahide.y@gmail.com | |
to: [masahide.y@gmail.com] | |
var: | |
c: 2 | |
d: [3, 4] |
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
m := make(map[interface{}]interface{}) | |
err = goyaml.Unmarshal([]byte(config), &m) | |
if err != nil { | |
panic(err) | |
} | |
//fmt.Printf("--- m:\n%# v\n\n", m) | |
pretty.Printf("--- m:\n%# v\n\n", m) |
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
$ go run main.go | |
--- m: | |
map[interface {}]interface {}{ | |
"mail_from": "masahide.y@gmail.com", | |
"to": []interface {}{ | |
"masahide.y@gmail.com", | |
}, | |
"var": map[interface {}]interface {}{ | |
"c": int(2), | |
"d": []interface {}{ | |
int(3), | |
int(4), | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment