Skip to content

StructTags

Eliot Hedeman edited this page Jan 18, 2020 · 1 revision

Struct Tags

Struct tags can be used to customize the parsing of arguments.

Supported tags

tag meaning
long Change the long form of flag name.This will default to the kebab case version of the field name on a struct
short Add a short version of your flag name. Will start with a single '-' instead of '--'
default The default value to be used for this flag if it is not provided.
help Help text for this flag
ignore Don't add this field to the set of flags to be parsed

Example

type ls struct {
	Path  string `short:"p" help:"path to list" default:"."`
}

Clone this wiki locally