Skip to main content

version.go

version.go - Overview

  1. Overview This file defines the build version information for the application, including the variant, version, git hash, build time, branch, and Go version. It also provides a function to pretty print this information.

  2. Detailed Documentation

variant string

  • Purpose: Stores the build variant. It is set via ldflags at build time.

version string

  • Purpose: Stores the build version. It is set via ldflags at build time.

hash string

  • Purpose: Stores the git commit hash of the build. It is set via ldflags at build time.

time string

  • Purpose: Stores the build time. It is set via ldflags at build time.

branch string

  • Purpose: Stores the git branch of the build. It is set via ldflags at build time.

Info Build

  • Purpose: An instance of the Build struct containing the build information.

type Build

  • Purpose: Represents build information.
  • Fields:
    • variant string: The build variant.
    • version string: The build version.
    • hash string: The git hash of the build.
    • time string: The build time.
    • branch string: The branch of the build.
    • goVersion string: The Go version used for the build.

Build.Variant() string

  • Purpose: Returns the build variant.
  • Returns: string: The build variant.

Build.Version() string

  • Purpose: Returns the build version.
  • Returns: string: The build version.

Build.Hash() string

  • Purpose: Returns the git hash of the build.
  • Returns: string: The git hash.

Build.Time() string

  • Purpose: Returns the build time.
  • Returns: string: The build time.

Build.Branch() string

  • Purpose: Returns the build branch.
  • Returns: string: The build branch.

Build.GoVersion() string

  • Purpose: Returns the Go version used for the build.
  • Returns: string: The Go version.

Build.PrettyPrint(cfg Config)

  • Purpose: Prints the build information in a formatted ASCII banner.
  • Parameters:
    • cfg Config: Configuration struct determining banner settings. The structure of Config is not defined in this file.
  • Returns: None

type Config

  • Purpose: Undefined struct that controls the behavior of PrettyPrint
  • Fields:
    • Banner BannerConfig: Another undefined struct, see below.

type BannerConfig

  • Purpose: Undefined struct that controls the behavior of PrettyPrint
  • Fields:
    • Enabled bool: If true, the banner is printed.
type Config struct {
Banner BannerConfig
}

type BannerConfig struct {
Enabled bool
}
  1. Code Examples None

Include in Getting Started: NO