Skip to content

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

@newink

Description

@newink

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions