Golang动态编译版本信息

前端之家收集整理的这篇文章主要介绍了Golang动态编译版本信息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. Makefile
  2. BUILD=`date +%FT%T%z`
    COMMIT_SHA1=`git rev-parse HEAD`
    
    LDFLAGS=-ldflags "-X main.BUILD=${BUILD} -X main.COMMIT_SHA1=${COMMIT_SHA1}"
    
    # Builds the project
    all: 
    
    app:
        go build ${LDFLAGS} -o ../bin/app/app github.com/winxxp/cmd/app
  3. main.go

  4. const (
        VERSION = "1.0.11"
        BUILD = "2016-11-18 16:40:00"
        COMMIT_SHA1 = ""
    )
原文链接:https://www.f2er.com/go/189136.html

猜你在找的Go相关文章