Skip to content

viper.GetStringMapString(key) doesn't work with AutomaticEnv  #911

@amir20

Description

@amir20

I currently use Viper to configure a Docker service. It doesn't make sense for people to change the entrypoint. So I rely on ENV vars heavily.

Following up with #608, using AutomaticEnv() with GetStringMapString() still doesn't work.

Looking through the source code, Viper branches based on the source. I debugged and found the function below gets an exception because it can't parse foo=bar style values with JSON. It also unexpectedly swallows and exception here :/

func ToStringMapString(i interface{}) map[string]string {
	v, _ := ToStringMapStringE(i)
	return v
}

As a user, I expect viper.Get***() to work regardless of the source.

I believe the chang would actually have to be in https://github.com/spf13/cast/blob/master/cast.go#L108-L110.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions