|
|
@@ -4,7 +4,7 @@ import (
|
|
|
"fmt"
|
|
|
"log"
|
|
|
|
|
|
- "gopkg.in/yaml.v2"
|
|
|
+ "gopkg.in/yaml.v2"
|
|
|
)
|
|
|
|
|
|
// An example showing how to unmarshal embedded
|
|
|
@@ -17,8 +17,8 @@ type StructA struct {
|
|
|
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"`
|
|
|
+ StructA `yaml:",inline"`
|
|
|
+ B string `yaml:"b"`
|
|
|
}
|
|
|
|
|
|
var data = `
|
|
|
@@ -31,11 +31,11 @@ func ExampleUnmarshal_embedded() {
|
|
|
|
|
|
err := yaml.Unmarshal([]byte(data), &b)
|
|
|
if err != nil {
|
|
|
- log.Fatal("cannot unmarshal data: %v", err)
|
|
|
+ log.Fatalf("cannot unmarshal data: %v", err)
|
|
|
}
|
|
|
- fmt.Println(b.A)
|
|
|
- fmt.Println(b.B)
|
|
|
- // Output:
|
|
|
- // a string from struct A
|
|
|
- // a string from struct B
|
|
|
+ fmt.Println(b.A)
|
|
|
+ fmt.Println(b.B)
|
|
|
+ // Output:
|
|
|
+ // a string from struct A
|
|
|
+ // a string from struct B
|
|
|
}
|