Files
golib/version
Nicolas JUHEL 49db5e2afb Add Package Config :
- major dependancies are :
  - golib/context config
  - golib/viper
- interface config extend :
  - golib/context config interface
  - component list
- interface component list :
  this interface implement all function to manage a collection of component. All component are registred with they config key.
  A component must implement basic function like start, stop, reload, defaultConfig...
  The main config json is set by calling all component config with the config key attached
  Each component have some status status like isStarted, isRunning, ...
  Each component must also declare his dependencies with other component. As that when start or reload is called,
  the component is sure that dependencies are still started or reloaded.
- They are 4 component for now : log, tls, headers and http server
- The config package will start a new context / cancelfunc on init to be sure to stop cleanly all component and process

Add Package Viper :
- this package is an helper to the config package with the spf13 viper lib
- this package can watch any change of a config file or can be connected to a remote config cluster like ETCD

Add Package Cobra :
- this package is an helper to make a CLI with flag / command
- this package is based on spf13 cobra has all method to be connected to viper golib
2022-02-21 07:32:44 +01:00
..
2022-02-21 07:32:44 +01:00
2020-07-14 13:28:48 +02:00
2022-02-21 07:32:44 +01:00

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
}