version

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VersionInfo

type VersionInfo 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:工作区有未提交改动
}

VersionInfo 是 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() VersionInfo

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 (VersionInfo) JSONString

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

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

func (VersionInfo) String

func (v VersionInfo) 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