version

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

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"`
	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