Documentation
¶
Overview ¶
Package version provides version information for the application. It is designed to be populated at build time using ldflags.
Features: - Semantic versioning support - Build time tracking - Git commit tracking - Go version tracking - Version comparison - Development/Release detection - Version validation
Usage:
Build with version information: go build -ldflags "-X github.com/goformx/goforms/internal/infrastructure/version.Version=1.0.0"
Get version information: info := version.GetInfo() fmt.Printf("Version: %s\n", info.Version)
Check version status: if info.IsDev() { // Handle development version }
Compare versions: if info.Compare(otherInfo) > 0 { // Handle version upgrade }
Validate version: if err := info.Validate(); err != nil { // Handle validation error }
The package integrates with: - Metrics (internal/infrastructure/metrics) - Logging (internal/infrastructure/logging) - Server (internal/infrastructure/server)
Index ¶
Constants ¶
const (
// UnknownVersion represents an unknown version value
UnknownVersion = "unknown"
)
Variables ¶
var ( // Version is the semantic version of the application Version = UnknownVersion // BuildTime is the time when the application was built BuildTime = UnknownVersion // GitCommit is the git commit hash of the build GitCommit = UnknownVersion // GoVersion is the version of Go used to build the application GoVersion = UnknownVersion )
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
Version string `json:"version"`
BuildTime string `json:"build_time"`
GitCommit string `json:"git_commit"`
GoVersion string `json:"go_version"`
}
Info contains version information
func (Info) Compare ¶ added in v0.1.5
Compare compares this version with another version Returns:
-1 if this version is less than the other version 0 if this version is equal to the other version 1 if this version is greater than the other version
func (Info) GetBuildTime ¶ added in v0.1.5
GetBuildTime returns the build time as a time.Time
func (Info) IsPreRelease ¶ added in v0.1.5
IsPreRelease returns true if the version is a pre-release version