version

package
v0.2.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// 未设置版本.
	VersionNotSet versionValue = 0
	// 启用版本.
	VersionEnabled versionValue = 1
	// 原始版本.
	VersionRaw versionValue = 2
)

定义一些常量.

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(fs *pflag.FlagSet)

AddFlags 在任意 FlagSet 上注册这个包的标志,这样它们指向与全局标志相同的值.

func PrintAndExitIfRequested

func PrintAndExitIfRequested()

PrintAndExitIfRequested 将检查是否传递了 `--version` 标志,如果是,则打印版本并退出.

func SetDynamicVersion

func SetDynamicVersion(dynamicVersion string) error

SetDynamicVersion overrides the version returned as the GitVersion from Get(). The specified version must be non-empty, a valid semantic version, and must match the major/minor/patch version of the default gitVersion.

func ValidateDynamicVersion

func ValidateDynamicVersion(dynamicVersion string) error

ValidateDynamicVersion ensures the given version is non-empty, a valid semantic version, and matched the major/minor/patch version of the default gitVersion.

func Version

func Version(name string, value versionValue, usage string) *versionValue

Version 包装了 VersionVar 函数.

func VersionVar

func VersionVar(p *versionValue, name string, value versionValue, usage string)

VersionVar 定义了一个具有指定名称和用法的标志.

Types

type Info

type Info struct {
	GitVersion   string `json:"gitVersion"`
	GitCommit    string `json:"gitCommit"`
	GitTreeState string `json:"gitTreeState"`
	BuildDate    string `json:"buildDate"`
	GoVersion    string `json:"goVersion"`
	Compiler     string `json:"compiler"`
	Platform     string `json:"platform"`
}

Info 包含了版本信息.

func Get

func Get() Info

Get 返回详尽的代码库版本信息,用来标明二进制文件由哪个版本的代码构建.

func (Info) String

func (info Info) String() string

String 返回人性化的版本信息字符串.

func (Info) Text

func (info Info) Text() string

Text 将版本信息编码为 UTF-8 格式的文本,并返回.

func (Info) ToJSON

func (info Info) ToJSON() string

ToJSON 以 JSON 格式返回版本信息.

Jump to

Keyboard shortcuts

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