appversion

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2021 License: LGPL-3.0 Imports: 4 Imported by: 0

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)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the application's version which must be set by the build system
	Version = "unknown"
	// BuildDate is the application' build timestamp wich must be set by the build system
	BuildDate = "unknown"
)

Functions

func Print

func Print()

Print formats the application's version and build date and prints the result

func String

func String() string

String formats the application's version and build date and returns the result as a string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL