Skip to content

Commit f91872e

Browse files
committed
Versions
1 parent 2983e2a commit f91872e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ARG TARGETARCH
2323

2424
RUN set -xe \
2525
&& GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \
26+
-ldflags="-X main.VersionName=${GIT_VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.BuildDate=$(date --utc)" \
2627
go build \
2728
-tags prod \
2829
-o ./bin/playground .

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func main() {
6363
flag.Parse()
6464
log.Printf("Use backend URL on :%s ...", *backendURL)
6565

66+
ShowVersion()
67+
6668
if err := waitForSandbox(10, 3*time.Second); err != nil {
6769
log.Println(err)
6870
return

version.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
var VersionName = "n/a"
8+
var GitCommit = "n/a"
9+
var BuildDate = "n/a"
10+
11+
func ShowVersion() {
12+
fmt.Printf("Version: %s\nCommit: %s\nDate: %s\n", VersionName, GitCommit, BuildDate)
13+
}

0 commit comments

Comments
 (0)