diff options
author | Thomas Hipp <thipp@suse.de> | 2017-08-03 15:00:55 +0200 |
---|---|---|
committer | Flavio Castelli <flavio@castelli.me> | 2017-08-08 09:42:05 +0200 |
commit | ecd75c368157b9dd0b92b5a12f06cc78d19c5de0 (patch) | |
tree | d0cab791a6763edca5afbbac67f659564cee205c /vendor/gopkg.in/yaml.v2/example_embedded_test.go | |
parent | 1aac0d73977bf5d9e9bac462d2302d28debe8605 (diff) | |
download | terraform-provider-libvirt-ecd75c368157b9dd0b92b5a12f06cc78d19c5de0.tar terraform-provider-libvirt-ecd75c368157b9dd0b92b5a12f06cc78d19c5de0.tar.gz |
vendor: depend on terraform v0.10.0
Signed-off-by: Thomas Hipp <thipp@suse.de>
Diffstat (limited to 'vendor/gopkg.in/yaml.v2/example_embedded_test.go')
-rw-r--r-- | vendor/gopkg.in/yaml.v2/example_embedded_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/gopkg.in/yaml.v2/example_embedded_test.go b/vendor/gopkg.in/yaml.v2/example_embedded_test.go new file mode 100644 index 00000000..c8b241d5 --- /dev/null +++ b/vendor/gopkg.in/yaml.v2/example_embedded_test.go @@ -0,0 +1,41 @@ +package yaml_test + +import ( + "fmt" + "log" + + "gopkg.in/yaml.v2" +) + +// An example showing how to unmarshal embedded +// structs from YAML. + +type StructA struct { + A string `yaml:"a"` +} + +type StructB struct { + // Embedded structs are not treated as embedded in YAML by default. To do that, + // add the ",inline" annotation below + StructA `yaml:",inline"` + B string `yaml:"b"` +} + +var data = ` +a: a string from struct A +b: a string from struct B +` + +func ExampleUnmarshal_embedded() { + var b StructB + + err := yaml.Unmarshal([]byte(data), &b) + if err != nil { + log.Fatal("cannot unmarshal data: %v", err) + } + fmt.Println(b.A) + fmt.Println(b.B) + // Output: + // a string from struct A + // a string from struct B +} |