version

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 8 Imported by: 0

README

License Go v1.9 Go Report Card GoDoc

Package version gets version information from git to go

 ..|'''.|   ||    .         ..|'''.|
.|'     '  ...  .||.   /\  .|'     '    ...
||    ....  ||   ||   (  ) ||    .... .|  '|.
'|.    ||   ||   ||     // '|.    ||  ||   ||
 ''|...'|  .||.  '|.'  //   ''|...'|   '|..|'
                      /(
                      {___

'||'  '|'                         ||
 '|.  .'    ....  ... ..   ....  ...    ...   .. ...
  ||  |   .|...||  ||' '' ||. '   ||  .|  '|.  ||  ||
   |||    ||       ||     . '|..  ||  ||   ||  ||  ||
    |      '|...' .||.    |'..|' .||.  '|..|' .||. ||.

FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Version runs git describe --always --long --tags --dirty and formats that info by default to stdout for you to view or pipe, or optionally in to a file (version.go) (see sample output below)

If you rather not include another package in your app then see verup. verup is a cmd you can execute at your main/cmd apps folder and it will do the same thing.

$ cat version.go
package main

//VarModTime is a UTC Unix time stamp
const VerModTime = 1530896805

//VarLong is the full version from Git command output
const VerLong = "0.2-14-g1051a2c-dirty"

//VarDirty means app was build with a git dir that contained modifications which had not been committed.
const VerDirty = true

//VarGit is the 7 hexadecimal digits version from Git.
const VerGit = "g1051a2c"

//VarTag is the Tag version from Git.
const VerTag = "0.2"

Alternative:

https://belief-driven-design.com/build-time-variables-in-go-51439b26ef9

Documentation

Overview

Package version gets version information from git to go

verup will create a file (version.go) with up to date version information from git. By default verup will output to stdout to view or pipe. Please check the flags.

cat version.go

package main

//VarModTime is a UTC Unix time stamp
const VerModTime = 1530896805

//VarLong is the full version from Git the command output
const VerLong = "0.2-14-g1051a2c-dirty"

//VarDirty means app was build with a git dir that contained modifications which had not been committed.
const VerDirty = true

//VarGit is the 7 hexadecimal digits version from Git.
const VerGit = "g1051a2c"

//VarTag is the Tag version from Git.
const VerTag = "0.2"

Index

Constants

View Source
const TEMPL = `` /* 318-byte string literal not displayed */

Variables

This section is empty.

Functions

func Out

func Out() error

func Save

func Save(file string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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