Documentation ¶
Index ¶
Constants ¶
View Source
const ( ServiceName = "service_name" ServiceVersion = "service_version" GitCommitSHA = "git_commit_sha" GitBranch = "git_branch" GoVersion = "go_version" )
Variables ¶
This section is empty.
Functions ¶
func WithBuildInfo ¶
WithBuildInfo fetches data from debug.BuildInfo and saves it to the kong.Vars
Saved variables:
- GoVersion ("go_version") – version of Go
- GitCommitSHA ("git_commit_sha") – SHA of the latest commit
func WithDumpEnvs ¶
WithDumpEnvs adds an optional flag '--dump-envs' to the service. If the application is run with this flag, it prints env-vars with default values and exits.
Usage:
ctx := kong.Parse(&app kongflag.WithDumpEnvs()) ctx.FatalIfErrorf(ctx.Run())
CLI usage:
$ go run main.go --dump-envs > example.env
nolint:dupl // False-positive here
func WithVersion ¶
WithVersion adds an optional flag '--version' to the service. If the application is run with this flag, it prints version and exits.
This option tries to extract version from build info. If it's empty, fallbackVersion is used.
Usage:
ctx := kong.Parse(&app, kongflag.PrintVersionFlag("v1.0.0")) ctx.FatalIfErrorf(ctx.Run())
CLI usage:
$ go run main.go --version example version: v1.0.0 git branch: main git revision: 795859ac3599bca75bb417bd0f97303f79289b65 go: go1.19.5
nolint:dupl,forbidigo // False-positive here
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.