Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML arrays can not be mapped to []string #120

Open
newink opened this issue May 20, 2022 · 0 comments
Open

YAML arrays can not be mapped to []string #120

newink opened this issue May 20, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@newink
Copy link

newink commented May 20, 2022

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/testify@v1.7.1/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/aconfig@v0.16.8/reflection.go:389 +0x36e

seems that array is just unexpected here:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants