Skip to content

Support slice with ParseEnv #114

Description

@artemklevtsov

System (please complete the following information):

  • OS: linux
  • GO Version: 1.19.4
  • Pkg Version: 2.1.8

Describe the bug

Slice not parser with environment variables.

To Reproduce

package main

import (
	"github.com/gookit/config/v2"
)

var version = "dev"

type conf struct {
	Name  string   `mapstructure:"name" default:"${NAME | Bob}"`
	Value []string `mapstructure:"value" default:"${VAL | val1}"`
}

func main() {

	config.WithOptions(
		config.ParseDefault,
		config.ParseEnv,
		config.Readonly,
	)

	err := config.LoadExists("")
	if err != nil {
		panic(err)
	}

	var cc conf
	if err := config.Decode(&cc); err != nil {
		panic(err)
	}
}

Actual behavior

panic: convert value type error

goroutine 1 [running]:
main.main()
        /run/media/unikum/UNIKUM-STORAGE/work/centrofinans/dev/kafka-tb-translator/tools/conf/main.go:29 +0xd1
exit status 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions