inject build info into main during build process

Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
This commit is contained in:
Mikolaj Pawlikowski
2018-12-06 16:31:14 +00:00
parent 4c82b29025
commit b90ebe4d19
2 changed files with 11 additions and 2 deletions
+3 -2
View File
@@ -37,5 +37,6 @@ export CGO_ENABLED=0
export GOARCH="${ARCH}"
go build \
-o ./bin/${BIN} \
./cmd/${BIN}
-ldflags "-X 'main.Version=${VERSION}' -X 'main.Build=`date`'" \
-o ./bin/${BIN} \
./cmd/${BIN}
+8
View File
@@ -29,7 +29,15 @@ import (
flags "github.com/jessevdk/go-flags"
)
// these will be injected during build in build.sh script to allow printing
var (
Version, Build string
)
func main() {
log.Println("Goldpinger version:", Version, "build:", Build)
// load embedded swagger file
swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "")
if err != nil {