version

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 3 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info added in v0.4.0

type Info struct {
	Version   string `json:"version"`              // module version(go install 嵌入,否则 (devel))
	Commit    string `json:"commit,omitempty"`     // vcs.revision(短哈希)
	BuildTime string `json:"build_time,omitempty"` // vcs.time(RFC3339)
	GoVersion string `json:"go_version"`           // 编译用的 Go 版本
	Modified  bool   `json:"modified,omitempty"`   // vcs.modified:工作区有未提交改动
}

Info 是 kite 的构建信息,经 debug.ReadBuildInfo() 读取。

go install 安装时自动嵌入 module version + vcs revision/time;非 install 构建 (如 go run / 本地 go build 无 vcs)则 version 为 (devel)、vcs 字段缺失。 doctor(#41)的「版本」检查项复用本类型与读取函数。

func LoadVersion

func LoadVersion() Info

LoadVersion 从 build info 读取版本信息。

主信息来源:

  • info.Main.Version:module version(go install 时为语义版本,否则 (devel))。
  • info.Settings 里的 vcs.revision / vcs.time / vcs.modified(需 vcs 元数据)。
  • info.GoVersion:编译用的 Go 版本。

commit 取短哈希(前 7 位,与 git 默认一致)。

func (Info) JSONString added in v0.4.0

func (v Info) JSONString() (string, error)

JSONString 渲染结构化 JSON(--json 模式用)。

func (Info) String added in v0.4.0

func (v Info) String() string

String 渲染人类可读的单行版本信息(供 cobra Version 模板用)。 例:`kite v0.1.0 (commit: 4a8047b, built: 2026-07-24, go: go1.25.0)` 无 vcs 信息时:`kite (devel, no vcs info)`

Jump to

Keyboard shortcuts

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