From 9080aac6f6dc9602e96672b268ac4397dc2e5c42 Mon Sep 17 00:00:00 2001 From: Yamil Rivera Date: Sun, 29 Mar 2020 21:53:51 -0400 Subject: [PATCH] Including 'Unexported fields' section to the docs --- mapstructure.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mapstructure.go b/mapstructure.go index daea3318..2b5e427c 100644 --- a/mapstructure.go +++ b/mapstructure.go @@ -100,6 +100,32 @@ // "address": "123 Maple St.", // } // +// Unexported fields +// +// Since unexported (private) struct fields cannot be set outside the package +// where they are defined, the decoder will simply skip them. +// +// For this output type definition: +// +// type Exported struct { +// private string // this unexported field will be skipped +// Public string +// } +// +// Using this map as input: +// +// map[string]interface{}{ +// "private": "I will be ignored", +// "Public": "I made it through!", +// } +// +// The following struct will be decoded: +// +// type Exported struct { +// private: "" // field is left with an empty string (zero value) +// Public: "I made it through!" +// } +// // Other Configuration // // mapstructure is highly configurable. See the DecoderConfig struct