Documentation
¶
Overview ¶
Package version is the single point of truth for the running aiwf binary's version, the latest published version on the Go module proxy, and the skew classification between any two versions.
Three version shapes show up in practice:
Tagged release — "v0.1.0", "v0.2.3-rc1". Returned by `runtime/debug.ReadBuildInfo` for binaries installed via `go install <module>@v0.1.0`. Tagged is true; Compare can classify against another tagged value.
Working-tree build — "(devel)". Returned for `go build` / `go run` from a working tree. Tagged is false; Compare always returns SkewUnknown when this shape is on either side.
Pseudo-version — "v0.0.0-20260503...-abc123" or "v0.1.0-pre.0.20060102150405-abcdef123456". Returned for `go install <module>@<branch-or-sha>` when the commit isn't tagged. Tagged is false; Compare returns SkewUnknown.
Pre-release suffixes on otherwise-clean tags ("v0.1.0-rc1") are recognized as tagged (the proxy serves them) but Compare returns SkewUnknown when either side carries any pre-release segment. This is a deliberate narrowing: the comparison aiwf needs is between concrete release versions; pre-release ordering is full-semver territory and lives in golang.org/x/mod/semver if we ever need it.
Index ¶
Constants ¶
const DefaultProxyURL = "https://proxy.golang.org"
DefaultProxyURL is the public Go module proxy operated by Google. Used when GOPROXY is unset.
const DevelVersion = "(devel)"
DevelVersion is the value reported by runtime/debug.ReadBuildInfo for binaries built from a working tree (`go build`, `go run`).
const LatestTimeout = 3 * time.Second
LatestTimeout caps the HTTP round-trip for proxy lookups. Three seconds is enough for proxy.golang.org from anywhere with working connectivity; a slow link returns an error rather than blocking `aiwf doctor` indefinitely.
Variables ¶
var ErrProxyDisabled = errors.New("module proxy disabled")
ErrProxyDisabled is returned by Latest when GOPROXY=off (or when the GOPROXY chain contains no http(s) entry). Callers that want optional skew detection should treat this as a non-fatal "skip the latest-version check" signal.
Functions ¶
func ModulePath ¶
func ModulePath() string
ModulePath returns the module path of the running aiwf binary, read from runtime/debug.ReadBuildInfo. Returns "" when build info is unavailable. Used by Latest to construct the proxy lookup URL.
The module path is the value declared in go.mod (e.g., "github.com/23min/aiwf"). For the go-install invocation that wants the cmd's package path (one level deeper), use PackagePath instead.
func PackagePath ¶
func PackagePath() string
PackagePath returns the package path of the running aiwf binary's main package, read from runtime/debug.ReadBuildInfo. Returns "" when build info is unavailable.
The package path is what `go install` accepts as its module-aware argument: e.g., "github.com/23min/aiwf/cmd/aiwf". Always equal to or below ModulePath in the import-path tree.
Types ¶
type Info ¶
type Info struct {
// Version is the raw version string. Always non-empty: a binary
// with no build info reports DevelVersion.
Version string
// Tagged is true when Version is a clean semver tag of the form
// `vMAJOR.MINOR.PATCH` (optionally with a pre-release or build
// suffix). False for DevelVersion and pseudo-versions.
Tagged bool
}
Info is a parsed version with a flag for whether it identifies a concrete tagged release (vs. devel or a pseudo-version).
func Current ¶
func Current() Info
Current returns the running binary's version Info, read from runtime/debug.ReadBuildInfo. Binaries built without module info report DevelVersion with Tagged=false.
func Latest ¶
Latest fetches the latest published version of the aiwf module from the Go module proxy. Honors GOPROXY (returns ErrProxyDisabled when set to `off` or to a chain with no http(s) entry). The HTTP round-trip is capped at LatestTimeout independently of ctx; ctx's cancellation also aborts the request.
Returns the parsed Info from the proxy response. The Info is Tagged=true for clean semver tags and Tagged=false for pseudo- versions (the proxy may serve either depending on the module's tag history).
type Skew ¶
type Skew int
Skew classifies the relationship between two Info values, comparing the first to the second. SkewUnknown is the safe default for any comparison that involves a non-tagged value or a pre-release suffix.