Documentation
¶
Index ¶
Constants ¶
const ( // VersionKey is the annotation key for the raw version. VersionKey = "go-utils_version" // CommitKey is the annotation key for the commit. CommitKey = "go-utils_commit" )
Variables ¶
var ErrInvalidShell = errors.New("invalid shell")
Functions ¶
func BuildUserAgent ¶
BuildUserAgent generates a value to be used with httpx.UserAgentTransport.
Example output: `example/v1.0.0-deadbeef (linux/amd64)`
func GenCompletion ¶
GenCompletion is a helper function that generates a shell completion script for the provided shell.
func GetVersion ¶
GetVersion gets the raw version set by WithVersion
func RegisterCompletionFlag
deprecated
RegisterCompletionFlag registers a flag to generate a shell completion script. Cobra typically uses a subcommand for this, but this flag is useful for executables that don't have any subcommands.
An initializer is registered which will trigger when the flag is set.
Deprecated: As of Cobra v1.9.0, the default completion command is always added.
Types ¶
type Option ¶
func WithVersion ¶
WithVersion takes a version string and sets the value to a cobra.Command. The current commit will be appended in parentheses, and the raw values will be added to the command's annotations.