version

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 9 Imported by: 0

README

Version package

Help manage package, version, build hash, tag ....

Example of implement

Create a package release :

/
...
  release/
    release.go
    version.go

In release.go file, we will create the public variable to be overwrite in build :

package release

type EmptyStruct struct{}

var (
	// Release the git tag of the current build, used with -X release.Release=$(git describe --tags HEAD || git describe --all HEAD)
	Release = "0.0"

	// Build the git commit of the current build, used with -X release.Build=$(git rev-parse --short HEAD)
	Build = "00000"

	// Date the current datetime RFC like for the build, used with -X release.Date=$(date +%FT%T%z)
	Date = "2017-10-21T00:00:00+0200"

	// Package the current package name of the build directory, used with -X release.Package=$(basename $(pwd))
	Package = ""

	// Package the current package name of the build directory, used with -X release.Description=...
	Description = "example of dexscription ..."

	// Author the name of the author for the current package, used with -X release.Author=...
	Author = "placeholder"

	// Prefix the package prefix could be used example for env var, used with -X config.Prefix=...
	Prefix = "EXPL"
)

In version.go file, we will implement the call to package golib/version :

package release

import "github.com/nabbar/golib/version"

var (
	vers version.Version
)

func init() {
	vers = version.NewVersion(version.License_MIT, release.Package, release.Description, release.Date, release.Build, release.Release, release.Author, release.Prefix, release.EmptyStruct{}, 1)
}

func GetVersion() version.Version {
	return vers
}

Documentation

Index

Constants

View Source
const (
	ErrorParamEmpty liberr.CodeError = iota + liberr.MinPkgVersion
	ErrorGoVersionInit
	ErrorGoVersionRuntime
	ErrorGoVersionConstraint
)
View Source
const (
	License_MIT license = iota
	License_GNU_GPL_v3
	License_GNU_Affero_GPL_v3
	License_GNU_Lesser_GPL_v3
	License_Mozilla_PL_v2
	License_Apache_v2
	License_Unlicense
	License_Creative_Common_Zero_v1
	License_Creative_Common_Attribution_v4_int
	License_Creative_Common_Attribution_Share_Alike_v4_int
	License_SIL_Open_Font_1_1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Version

type Version interface {
	CheckGo(RequireGoVersion, RequireGoContraint string) liberr.Error

	GetAppId() string
	GetAuthor() string
	GetBuild() string
	GetDate() string
	GetTime() time.Time
	GetDescription() string
	GetHeader() string
	GetInfo() string
	GetPackage() string
	GetRootPackagePath() string
	GetPrefix() string
	GetRelease() string

	GetLicenseName() string
	GetLicenseLegal(addMoreLicence ...license) string
	GetLicenseFull(addMoreLicence ...license) string
	GetLicenseBoiler(addMoreLicence ...license) string

	PrintInfo()
	PrintLicense(addlicence ...license)
}

func NewVersion

func NewVersion(License license, Package, Description, Date, Build, Release, Author, Prefix string, emptyInterface interface{}, numSubPackage int) Version

Jump to

Keyboard shortcuts

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