buildinfo

package
v0.3.4 Latest Latest
Warning

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

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

Documentation

Overview

Package buildinfo stores information about an applications current build.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRunNameForProgram

func GetRunNameForProgram() string

GetRunNameForProgram returns the base name of the running program.

Types

type Info

type Info struct {
	// Architecture is the build processor architecture.
	Architecture string
	// BuiltBy who/what build this version.
	BuiltBy string
	// Date compiled.
	Date string
	// Commit used for build.
	Commit string
	// CompiledName compile name used for build.
	CompiledName string
	// Compiler used to build
	Compiler string
	// OperatingSystem is the build operating system.
	OperatingSystem string
	// RunName is the name of the program obtained from arg[0].
	RunName string
	// Start dir is the working directory when the program starts.
	StartDir string
	// Version is the version of the program.
	Version string
}

Info is information about the build.

func GetBuildInfo

func GetBuildInfo(ctx context.Context) Info

GetBuildInfo returns the run context.

func NewInfo

func NewInfo(version, commit, date, builtBy, compiledName string) Info

NewInfo creates a new info from the passed arguments. Use NewInfo to pass in the information captured from link flags.

Eg --ldflags "-s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} -X main.builtBy={{ .Env.BUILTBY }}".

func (Info) BasicVersion added in v0.2.1

func (info Info) BasicVersion() string

BasicVersion converts the build info to a string.

func (Info) NewContext

func (info Info) NewContext(ctx context.Context) context.Context

NewContext creates a new context containing the build information.

func (Info) String

func (info Info) String() string

String converts the build info to a string.

func (Info) TabularVersion added in v0.2.1

func (info Info) TabularVersion() string

TabularVersion converts the build info to a tabular string.

Jump to

Keyboard shortcuts

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