From 0f774a4c4b866cd56b3a298a8a28a89a0d5fa25b Mon Sep 17 00:00:00 2001 From: Dave Shanley Date: Sat, 3 Dec 2022 11:49:57 -0500 Subject: [PATCH] Updated example code and readme to help explain encoding issues #34 Signed-off-by: Dave Shanley --- README.md | 7 +++++-- document_test.go | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 799084d..2ccbdd8 100644 --- a/README.md +++ b/README.md @@ -302,9 +302,11 @@ import ( ) // define an example struct representing a cake +// super important to remember to use hints/meta-data to map properties correctly. type cake struct { - Candles int - Frosting string + Candles int `yaml:"candles"` + Frosting string `yaml:"frosting"` + Some_Strange_Var_Name string `yaml:"someStrangeVarName"` } // define a struct that holds a map of cake pointers. @@ -340,6 +342,7 @@ func main() { someCake: candles: 10 frosting: blue + someStrangeVarName: mapping is required to extract these. anotherCake: candles: 1 frosting: green diff --git a/document_test.go b/document_test.go index 84a193b..a4cc181 100644 --- a/document_test.go +++ b/document_test.go @@ -546,8 +546,9 @@ func ExampleNewDocument_unpacking_extensions() { // define an example struct representing a cake type cake struct { - Candles int - Frosting string + Candles int `yaml:"candles"` + Frosting string `yaml:"frosting"` + Some_Strange_Var_Name string `yaml:"someStrangeVarName"` } // define a struct that holds a map of cake pointers. @@ -580,6 +581,7 @@ components: someCake: candles: 10 frosting: blue + someStrangeVarName: something anotherCake: candles: 1 frosting: green