Skip to content

Latest commit

 

History

History

version

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

KDGoLib version package

Usage

  • import package
import "github.com/tsaikd/KDGoLib/version"
  • initialize version
func init() {
	version.VERSION = "0.0.1"
}
  • show version in somewhere
func main() {
	fmt.Println(version.String())
}
  • config LDFLAGS when compile time
githash="$(git rev-parse HEAD | cut -c1-8)"
buildtime="$(date +%Y-%m-%d)"

LDFLAGS="${LDFLAGS} -X github.com/tsaikd/KDGoLib/version.BUILDTIME ${buildtime}"
LDFLAGS="${LDFLAGS} -X github.com/tsaikd/KDGoLib/version.GITCOMMIT ${githash}"

go build -ldflags "${LDFLAGS}"