Documentation
¶
Overview ¶
Package flag provides helpers for defining and parsing command-line flags in go-service.
This package is a small wrapper around the standard library `flag` package that standardizes a few flag conventions used across go-service, especially configuration source selection.
Configuration input flag (-i) ¶
Many go-service applications accept an "-i" flag that selects where configuration should be loaded from. The conventional value format is:
"kind:location"
Common examples:
- "file:/path/to/config.yaml" to read configuration from a file (decoder selected by extension)
- "env:MY_CONFIG" to read configuration from an environment variable (typically "<ext>:<base64-content>")
The `FlagSet` type in this package supports installing this convention via `(*FlagSet).AddInput` and retrieving it via `(*FlagSet).GetInput`. The config subsystem (`config.NewDecoder`) consumes this value to route to the appropriate decoder.
Start with `NewFlagSet`, `FlagSet.AddInput`, and `FlagSet.GetInput`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlagSet ¶
FlagSet represents a set of defined flags.
It wraps flag.FlagSet and provides optional support for the conventional go-service configuration input flag ("-i") used by the config subsystem to route decoding.
This type is intentionally minimal: you can still use the embedded *flag.FlagSet to define and parse arbitrary flags.
func NewFlagSet ¶
NewFlagSet creates a new FlagSet with the given name.
The returned FlagSet wraps the standard library flag.FlagSet and uses flag.ContinueOnError so callers can handle parse errors explicitly (instead of terminating the process).
func (*FlagSet) AddInput ¶
AddInput adds the conventional configuration input flag ("-i") to the flag set.
The value is treated as an opaque "kind:location" string that the config package interprets. Common examples include:
- "file:/path/to/config.yaml" (decode kind inferred from file extension)
- "env:MY_CONFIG" (read config payload from environment variable MY_CONFIG)
The provided value is used as the default.