ldflags

package module
v0.0.0-...-6ea18db Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: Apache-2.0 Imports: 0 Imported by: 9

README

Release GitHub Maintainability Go Report Card GoDoc GoDoc FOSSA Status time tracker

ldflags package

Package to store on-build extra information: version(tag), build hash, build time

Usage

Add this package as dependency to YOUR package:

go get github.com/version-go/ldflags 

Then on build of YOUR package just add extra:

go build -ldflags "-X 'github.com/version-go/ldflags.buildVersion=0.1.0' -X 'github.com/version-go/ldflags.buildHash=9e7637c' -X 'github.com/version-go/ldflags.buildTime=Sun Oct  4 20:57:29 CEST 2020'" .

Or do it automatically based on existing git/data:

go build -ldflags "-X 'github.com/version-go/ldflags.buildVersion=$(git describe --abbrev=0 --tags)' -X 'github.com/version-go/ldflags.buildHash=$(git rev-parse --short HEAD)' -X 'github.com/version-go/ldflags.buildTime=$(date)'" .

will store current latest tag, commit hash and build time.

License

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build() string

Build returns build hash if provided, "unknown" otherwise

func New

func New() *buildInfo

New works as a singleton

func Time

func Time() string

Time returns build time if provided, "unknown" otherwise

func Version

func Version() string

Version returns build version if provided, "unknown" otherwise

Types

This section is empty.

Jump to

Keyboard shortcuts

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