-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b68d3b2
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
VERSION := $(shell cat VERSION) | ||
BUILD_USER := $(shell whoami) | ||
BUILD_DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') | ||
GIT_COMMIT := $(shell git rev-list -1 HEAD) | ||
GIT_SHORT_COMMIT := $(shell git rev-parse --short HEAD) | ||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
|
||
|
||
GOLDFLAGS = "-X main.Version=$(VERSION) -X main.GitBranch=$(GIT_BRANCH) -X main.GitCommit=$(GIT_COMMIT) -X main.BuildUser=$(BUILD_USER) -X main.BuildDate=$(BUILD_DATE)" | ||
|
||
build: | ||
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags $(GOLDFLAGS) -o main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
func main() { | ||
versionFlag := flag.Bool("version", false, "Print version information and quit") | ||
flag.Parse() | ||
if *versionFlag { | ||
printVersion() | ||
} | ||
} | ||
|
||
var ( | ||
Version string | ||
GitBranch string | ||
GitCommit string | ||
BuildUser string | ||
BuildDate string | ||
) | ||
|
||
func printVersion() { | ||
fmt.Printf(`version %s | ||
build user: %s | ||
build date: %s | ||
go version: %s | ||
platform: %s/%s | ||
git branch: %s | ||
git commit: %s | ||
`, Version, BuildUser, BuildDate, runtime.Version(), runtime.GOOS, runtime.GOARCH, GitBranch, GitCommit) | ||
} |