Home >Backend Development >Golang >How to Unmarshal YAML into a Go struct with unexported fields?
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> <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!