Discover Packages
github.com/gaaf/go-appversion
package
module
Version:
v0.0.3
Opens a new window with list of versions in this module.
Published: Jul 26, 2021
License: LGPL-3.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
Go-Version
Add GIT version and build timestamp to a project.
Usage
import "github.com/gaaf/go-appversion"
main() {
appversion.Print()
}
Example Makefile
.DEFAULT_GOAL := build
export GOBIN=${CURDIR}/bin/
MODULE:=github.com/gaaf/go-appversion
VERSION:=$(shell git describe --tags --long --always --dirty)
BUILD_DATE:=$(shell date +%FT%T%z)
TARGET?=./...
BUILDFLAGS?=-trimpath
LDFLAGS:=-X $(MODULE).Version=$(VERSION) -X $(MODULE).BuildDate=$(BUILD_DATE)
# No dependency management by make, only by the go tool
.PHONY: build run prod debug clean
# Build the project
build:
go install -v $(BUILDFLAGS) -ldflags "$(LDFLAGS)" $(TARGET)
# Run with same options as build
run:
go run -v $(BUILDFLAGS) -ldflags "$(LDFLAGS)" $(TARGET)
# Production builds have symbols stripped
prod: BUILDFLAGS += -a
prod: LDFLAGS += -s -w
prod: build
# Start the delve debugger
debug:
dlv debug -ldflags "$(LDFLAGS)" $(TARGET)
# Clean project: delete binaries
clean:
go clean -v $(BUILDFLAGS) -i $(TARGET)
Expand ▾
Collapse ▴
Documentation
¶
View Source
var (
Version = "unknown"
BuildDate = "unknown"
)
Print formats the application's version and build date and prints the result
String formats the application's version and build date and returns the result as a string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.