Skip to content

Example of using map of structs in config, example of using env-separator #143

Open
@Larleyt

Description

@Larleyt

The docs say:
env-separator="<value>" - custom list and map separator. If not set, the default separator , will be used;
implying maps with arbitrary keys are supported. Yet, there's no example for it.

It is unclear how to assign env variable to a attribute of a struct which is a value of a map:

Let's say we have:
config.go:

Animals map[string]Animal  `yaml:"animals" env:"ANIMALS"`

Animal struct {
   Name: string `yaml:"name" env:"NAME"`
}

config.yaml:

animals: 
    dog:
        name: "Rocky"
    cat: 
        name: "Jack"
  1. How do I provide names through env vars?
    Is it ANIMALS_DOG_NAME/ANIMALS_CAT_NAME or what?

  2. What's env-separator is about?

@ilyakaznacheev

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