Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.
This repository was archived by the owner on May 26, 2023. It is now read-only.

Support Multi Value Flags in Config #38

@agorman

Description

@agorman

For some flags I create my own type so I can apply the flag multiple times and store it in a slice. It looks something like this.

./myapp -multi 1 -multi 2 -multi 3

type arrayFlags []string

func (i *arrayFlags) String() string {
	return "[]"
}

func (i *arrayFlags) Set(value string) error {
	*i = append(*i, value)
	return nil
}

var multi arrayFlags

flag.Var(&multi , "multi", "Apply this multiple times")

This works great but when I try to use a config I always only get the first value.

multi 1
multi 2
multi 3

./myapp -config my.conf

The value of multi is always just [1].

Is there a way I can get this to work when using a configuration file?

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