version

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 2 Imported by: 1

README

Version Package

This package provides version information for the application. The variables can be configured at build time using ldflags.

Usage

Import the package in your code:

import "github.com/metalagman/appkit/version"

fmt.Println(version.String())

Build Configuration

Use -ldflags to set the version information during build:

go build -ldflags "-X github.com/metalagman/appkit/version.version=v1.0.0 \
                   -X github.com/metalagman/appkit/version.metadata=beta.1 \
                   -X github.com/metalagman/appkit/version.gitCommit=$(git rev-parse HEAD) \
                   -X github.com/metalagman/appkit/version.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)"

Variables

  • version: The version of the application (e.g., v1.2.3).
  • metadata: Extra build time data (e.g., beta.1).
  • gitCommit: The source control revision (e.g., git commit hash).
  • buildDate: The timestamp when the binary was built.

Documentation

Overview

Package version provides version information for the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVersion

func GetVersion() string

GetVersion returns the semver string of the version.

func String

func String() string

String returns a string representation of the version information.

Types

type BuildInfo

type BuildInfo struct {
	// Version is the current semver.
	Version string `json:"version,omitempty"`
	// GitCommit is the git sha1.
	GitCommit string `json:"git_commit,omitempty"`
	// BuildDate is the date the application was built.
	BuildDate string `json:"build_date,omitempty"`
	// GoVersion is the version of the Go compiler used.
	GoVersion string `json:"go_version,omitempty"`
	// Platform is the platform the application was built for.
	Platform string `json:"platform,omitempty"`
}

BuildInfo describes the compile time information.

func Get

func Get() BuildInfo

Get returns build info.

Jump to

Keyboard shortcuts

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