aconfig
aconfig copied to clipboard
YAML arrays can not be mapped to []string
YAML:
WriteRoles:
- Writer
ReadRoles:
- Writer
- Reader
ListRoles:
- Writer
- Reader
Struct:
type TestConfig struct {
ReadRoles []Role `yaml:"ReadRoles"`
WriteRoles []Role `yaml:"WriteRoles"`
ListRoles []Role `yaml:"ListRoles"`
}
type Role string
Error:
suite.go:63: test panicked: string Writer
goroutine 26 [running]:
runtime/debug.Stack()
/usr/local/opt/go/libexec/src/runtime/debug/stack.go:24 +0x7a
github.com/stretchr/testify/suite.failOnPanic(0xc000545040)
/Users/sivanov/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:63 +0x54
panic({0x255a9c0, 0xc000088130})
/usr/local/opt/go/libexec/src/runtime/panic.go:844 +0x25a
github.com/cristalhq/aconfig.mii({0x255a9c0, 0xc000191a50})
/Users/sivanov/go/pkg/mod/github.com/cristalhq/[email protected]/reflection.go:389 +0x36e
seems that array is just unexpected here: