Documentation ¶
Overview ¶
Package build provides details of the built binary The details are set using ldflags.
The ldflags can be set manually for testing locally: `go build -ldflags "-X github.com/srimaln91/go-make.version=$(git describe --tags) -X github.com/srimaln91/go-make.date=$(date -u +%Y-%m-%d-%H:%M:%S-%Z)"`
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( PRINTER_TABLE = TablePrinter{Writer: os.Stdout} PRINTER_STRING = StringPrinter{Writer: os.Stdout} PRINTER_SINGLE_LINE = SingleLinePrinter{Writer: os.Stdout} )
Functions ¶
func CheckVersion ¶
func CheckVersion(printer ...Printer)
CheckVersion checks --version os argument and prints the binary build details in the console
func String ¶
func String() string
String returns build details as a string with formatting suitable for console output. Ex: Build Details:
Version: v0.5.0 Go Runtime: go1.12.9 Git Commit: bc2e7ce8edc4aa85cc258890e0e4381630cbf5f8 OS/Arch: linux/amd64 Built On: 2019-10-05-12:17:29-UTC
func Table ¶
func Table() string
Table returns build details as a table Suitable for console output Ex:
+----------------+------------+------------------------------------------+-------------+-------------------------+ | BINARY VERSION | GO VERSION | GIT COMMIT | OS/ARCH | BUILT | +----------------+------------+------------------------------------------+-------------+-------------------------+ | v0.5.0-dirty | go1.12.9 | bc2e7ce8edc4aa85cc258890e0e4381630cbf5f8 | linux/amd64 | 2019-10-05-12:17:29-UTC | +----------------+------------+------------------------------------------+-------------+-------------------------+
Types ¶
type Details ¶
type Details struct { Version string `json:"version,omitempty"` GoRuntime string `json:"go_runtime,omitempty"` GitCommit string `json:"git_commit,omitempty"` OSArch string `json:"os_arch,omitempty"` Date string `json:"date,omitempty"` }
Details represents known data for a given build
type SingleLinePrinter ¶ added in v1.2.0
func (SingleLinePrinter) Print ¶ added in v1.2.0
func (p SingleLinePrinter) Print(details Details) error
type StringPrinter ¶ added in v1.2.0
func (StringPrinter) Print ¶ added in v1.2.0
func (p StringPrinter) Print(details Details) error
type TablePrinter ¶ added in v1.2.0
func (TablePrinter) Print ¶ added in v1.2.0
func (p TablePrinter) Print(details Details) error