Documentation
¶
Overview ¶
Package v simplifies printing version information of an application.
Add the following to your main.go
package main import ( "log" "github.com/metal-stack/v" ) func main() { log.Info("application", "version", v.V) }
And in your Makefile:
.ONESHELL: SHA := $(shell git rev-parse --short=8 HEAD) GITVERSION := $(shell git describe --long --all) BUILDDATE := $(shell date -Iseconds) VERSION := $(or ${VERSION},devel) BINARY := application ${BINARY}: clean test GGO_ENABLED=0 \ GO111MODULE=on \ go build \ -tags netgo \ -ldflags "-X 'github.com/metal-stack/v.Version=$(VERSION)' \ -X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \ -X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \ -X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)'" \ -o application
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Version of the application Version = "version not set, please build your app with appropriate ldflags, see https://github.com/metal-stack/v for reference" // Revision of the application Revision = "" // GitSHA1 of the application GitSHA1 = "" // BuildDate of the application BuildDate = "" )
View Source
var V = &version{}
V the version
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.