version

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package version provides application version and build metadata for API endpoints.

Basic usage:

router.GET("/version", func(c *gin.Context) {
    c.JSON(http.StatusOK, version.Get())
})

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Version

type Version struct {
	Name        string `json:"name,omitempty"`
	Version     string `json:"version,omitempty"`
	Edition     string `json:"edition,omitempty"`     // application edition (e.g. free, team, enterprise)
	Environment string `json:"environment,omitempty"` // runtime environment (e.g. production, staging)
	GoVersion   string `json:"goVersion,omitempty"`   // Go toolchain version used to build the binary
	BuildInfo   string `json:"buildInfo,omitempty"`   // module version from the embedded build info
}

Version holds application version and build metadata typically returned by a version API endpoint.

func Get

func Get() Version

Get returns a Version populated from the application environment configuration and the embedded Go build info. It is intended for API version endpoints; CLI processes may not have the required environment variables set.

Example

ExampleGet shows how to expose build and runtime metadata via a /version HTTP endpoint. Requires env.InitEnv to be called at application startup.

package main

import (
	"fmt"

	"github.com/phcp-tech/common-library-golang/version"
)

func main() {
	v := version.Get()
	fmt.Printf("name=%s version=%s env=%s\n", v.Name, v.Version, v.Environment)
}

Jump to

Keyboard shortcuts

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