The issue presented in the code is that the struct fields are not exported. To make them exported, use capital letters at the beginning of the field names like so:
type Config struct {</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">FooBar string `yaml:"foo_bar"`
}
The code will now successfully unmarshal the YAML data into the Config struct.
The above is the detailed content of How to Unmarshal YAML into a Go struct with unexported fields?. For more information, please follow other related articles on the PHP Chinese website!