configor icon indicating copy to clipboard operation
configor copied to clipboard

Examples should decapitalize yaml fields in struct

Open sundowndev opened this issue 5 years ago • 4 comments

var Config = struct {
	Contacts []struct {
		Name  string
		Email string `required:"true"`
	}
}{}

configor.Load(&Config, "config.yml")
fmt.Println(Config)
// log: {[]}
contacts:
- name: i test
email: [email protected]

sundowndev avatar Feb 02 '20 14:02 sundowndev

Can be fixed by decapitalizing Name, Contacts, and Email in your struct

gidoBOSSftw5731 avatar May 11 '20 07:05 gidoBOSSftw5731

Works as designed - use proper indentation in your yaml file.

contacts:
  - name: i test
    email: [email protected]

cbndr avatar Jun 03 '20 13:06 cbndr

I think issue was I forgot to decapitalize fields (yaml:"name") in my struct, as @gidoBOSSftw5731 mentioned.

sundowndev avatar Jun 03 '20 13:06 sundowndev

Reopening so maintainer consider mentioning this in README examples.

sundowndev avatar Jun 03 '20 13:06 sundowndev