info

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package info provides the build information of a command or module.

Index

Constants

View Source
const (
	// RepoPathSepNum is the number of the repository path separator.
	RepoPathSepNum = 3
	// DebugRevisionLen is the length of the debug revision.
	DebugRevisionLen = 12
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// Path contains the package path of the command or module.
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
	// Repo contains the repository of the command or module.
	Repo string `yaml:"repo,omitempty" json:"repo,omitempty"`
	// Version contains the actual version of the command or module.
	Version string `yaml:"version,omitempty" json:"version,omitempty"`
	// Revision contains the revision of the command or module from version
	// control system.
	Revision string `yaml:"revision,omitempty" json:"revision,omitempty"`
	// Build contains the build time of the command or module.
	Build time.Time `yaml:"build,omitempty" json:"build,omitempty"`
	// Commit contains the last commit time of the command or module from the
	// version control system.
	Commit time.Time `yaml:"commit,omitempty" json:"commit,omitempty"`
	// Dirty flags whether the build of the command or module is based on a
	// dirty local repository state.
	Dirty bool `yaml:"dirty,omitempty" json:"dirty,omitempty"`
	// Checksum contains the check sum of the command or module.
	Checksum string `yaml:"checksum,omitempty" json:"checksum,omitempty"`

	// Go contains the go version the command or module was build with.
	Go string `yaml:"go,omitempty" json:"go,omitempty"`
	// Platform contains the build platform the command or module was build
	// for.
	Platform string `yaml:"platform,omitempty" json:"platform,omitempty"`
	// Compiler contains the actual compiler the command or module was build
	// with.
	Compiler string `yaml:"compiler,omitempty" json:"compiler,omitempty"`
}

Info provides the build information of a command or module.

func NewInfo

func NewInfo(path, version, revision, build, commit string, dirty bool) *Info

NewInfo returns the build information of a command or module using given custom version and custom build time using RFC3339 format. The provided version must follow semantic versioning as supported by go.

func (*Info) AdjustVersion

func (info *Info) AdjustVersion() *Info

AdjustVersion adjusts the version of the build information of a command or module if the version does not follow semantic versioning as supported by go. The version is adjusted using the revision and commit time of the build information. If the revision is not available the version is not changed.

func (*Info) String

func (info *Info) String() string

String returns the build information of a command or module as structured JSON string.

func (*Info) UseDebug

func (info *Info) UseDebug(build *debug.BuildInfo, ok bool) *Info

UseDebug enriches the build information of a command or module using the given debug build information. If the debug build information is not available the build information is not changed.

Jump to

Keyboard shortcuts

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