gover

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

README

gover GoDoc License

Provide some simple public version variables.

Install

go get -u github.com/xgfone/gover

Usage

package main

import (
	"fmt"

	"github.com/xgfone/gover"
)

func main() {
	fmt.Println(gover.Text())
}

Build App

You need build your repo with the commands as follow

COMMIT=$(shell git rev-parse HEAD)
VERSION=$(shell git describe --tags)
BUILD_DATE=$(shell date +"%s")

go build -ldflags "-X github.com/xgfone/gover.Commit=$COMMIT -X github.com/xgfone/gover.BuildTime=$BUILD_DATE -X github.com/xgfone/gover.Version=$VERSION"

Or, use the shell script build.sh or the Makefile.

Documentation

Overview

Package gover provides some simple public version variables.

Index

Constants

This section is empty.

Variables

View Source
var (
	Commit    string
	Version   string
	BuildTime string
	StartTime time.Time
)

Some variables

View Source
var TextTemplate = `` /* 143-byte string literal not displayed */

TextTemplate is used to format the text version, which is a go text template.

Functions

func GetBuildTime

func GetBuildTime() time.Time

GetBuildTime converts the string BuildTime to time.Time.

func GetElapsedTime added in v0.2.0

func GetElapsedTime() time.Duration

GetElapsedTime returns the elapsed time since the application starts.

func GetShortCommit

func GetShortCommit() string

GetShortCommit returns the short commit.

func Text added in v0.3.0

func Text() string

Text returns the version information by the text template "TextTemplate", and supports the context datas as follow:

.GOOS
.GOARCH
.GoVersion
.Version
.Commit
.BuildTime
.StartTime

Types

This section is empty.

Jump to

Keyboard shortcuts

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