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

Support slice with ParseEnv #114

Closed
artemklevtsov opened this issue Jan 9, 2023 · 1 comment
Closed

Support slice with ParseEnv #114

artemklevtsov opened this issue Jan 9, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@artemklevtsov
Copy link

artemklevtsov commented Jan 9, 2023

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
@inhere inhere added the enhancement New feature or request label Jan 10, 2023
@inhere inhere closed this as completed in 08b995e Feb 11, 2023
@inhere
Copy link
Member

inhere commented Feb 11, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants