bininfo

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 2 Imported by: 18

Documentation

Overview

Package bininfo contains information about the current binary and process. Most of the information available through this interface is filled at build time using the -X linker flag.

This package can be considered an interface between the application (which provides the requisite data at build time and runtime) and various places around our internal libraries (which use this data, e.g. to construct User-Agent headers or log messages).

When using <https://github.com/sapcc/go-makefile-maker>, go-makefile-maker will detect when go-api-declarations is listed as a dependency in the application's go.mod file and generate the appropriate linker flags automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDate

func BuildDate() string

BuildDate returns the buildDate string provided at build time, or "" if none was provided.

func BuildDateOr

func BuildDateOr(fallback string) string

BuildDateOr returns the build date string, or the fallback value if none is known. A common invocation is `BuildDateOr("unknown")`.

func Commit

func Commit() string

Commit returns the commit string provided at build time, or "" if none was provided.

func CommitOr

func CommitOr(fallback string) string

CommitOr returns the commit string provided at build time, or the fallback value if none was provided. A common invocation is `CommitOr("unknown")`.

func Component

func Component() string

Component returns the name of the current binary, followed by the name of the current process's task if one has provided via SetTaskName(). This string can be used to identify the current process, e.g. in User-Agent headers.

For example, the command `tenso worker` calls `SetTaskName("worker")`, so Component() will return "tenso-worker".

func HandleVersionArgument added in v1.10.9

func HandleVersionArgument()

HandleVersionArgument prints the version string and exits if the first argument to the program is --version

func SetTaskName

func SetTaskName(name string)

SetTaskName identifies the subcommand selected for the current process. This setting influences the output of Component().

func Version

func Version() string

Version returns the version string provided at build time, or "" if none was provided.

func VersionOr

func VersionOr(fallback string) string

VersionOr returns the version string provided at build time, or the fallback value if none was provided. A common invocation is `VersionOr("unknown")`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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