built

package module
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: BSD-3-Clause Imports: 0 Imported by: 0

README

built

A simple set of string vars defined at compile time for the Version of the build (a git tag and commit), Timestamp of the build (a timestamp), and CompiledBy (go version and platform).

As this package simply exports three getter funcs for three simple vars and setting them happens at compile time, usage is probably better if you copy and paste this code into your package main. This is in keeping with the proverb: "A little copying is better than a little dependency."

for example

A Makefile might look like...

BIN=example
HEAD=$(shell git describe --dirty --long --tags 2> /dev/null  || git rev-parse --short HEAD)
TIMESTAMP=$(shell date '+%Y-%m-%dT%H:%M:%S %z %Z')

LDFLAGS="-X 'github.com/henderjon/built.version=$(HEAD)' -X 'github.com/henderjon/built.timestamp=$(TIMESTAMP)' -X 'github.com/henderjon/built.compiledBy=$(shell go version)'"

all: darwin64

.PHONY: dep
dep:
	go mod vendor

.PHONY: clean
clean:
	rm -f $(BIN) $(BIN)-*

.PHONY: darwin64
darwin64: clean
	env GOOS=darwin GOARCH=amd64 go build -ldflags $(LDFLAGS) -o $(BIN)-darwin64-$(HEAD)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompiledBy

func CompiledBy() string

CompiledBy returns the build timestamp set when the binary was built

func Timestamp

func Timestamp() string

Timestamp returns the build timestamp set when the binary was built

func Version

func Version() string

Version returns the build version set when the binary was built

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL