Merge branch 'feat/build-revision' into 'main'

feat: add build revision and build time

See merge request opensource/answer!71
This commit is contained in:
linkinstar 2022-10-18 04:26:50 +00:00
commit a2cc79ae82
3 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,8 @@ DIR_SRC=./cmd/answer
DOCKER_CMD=docker
GO_ENV=CGO_ENABLED=0
GO_FLAGS=-ldflags="-X main.Version=$(VERSION) -X 'main.Time=`date`' -extldflags -static"
Revision=$(shell git rev-parse --short HEAD)
GO_FLAGS=-ldflags="-X main.Version=$(VERSION) -X main.Revision=$(Revision) -X 'main.Time=`date`' -extldflags -static"
GO=$(GO_ENV) $(shell which go)
build:

View File

@ -18,7 +18,7 @@ var (
)
func init() {
rootCmd.Version = Version
rootCmd.Version = fmt.Sprintf("%s\nrevision: %s\nbuild time: %s", Version, Revision, Time)
initCmd.Flags().StringVarP(&dataDirPath, "data-path", "C", "/data/", "data path, eg: -C ./data/")

View File

@ -20,6 +20,10 @@ var (
Name = "answer"
// Version is the version of the project
Version = "development"
// Revision is the git short commit revision number
Revision = ""
// Time is the build time of the project
Time = ""
// log level
logLevel = os.Getenv("LOG_LEVEL")
// log path