Skip to content

Commit 88e74e0

Browse files
committed
feat: make buildDate as optional
1 parent 4080361 commit 88e74e0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

version.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ var (
2727
GitTreeState = unknownProperty
2828
// GitTag shows latest tag if injected by go -ldflags, otherwise it is invisible.
2929
GitTag = unknownProperty
30-
// BuildDate shows the built time for the associated binary.
31-
// Expect to be filled via go -ldflags during compiling.
30+
// BuildDate shows the built time for the associated binary if injected by go -ldflags. otherwise it is invisible.
3231
BuildDate = unknownProperty
3332
// Platform composes with GOARCH and GOOS automatically.
3433
Platform = unknownProperty
@@ -72,7 +71,10 @@ func Version() {
7271
xprintf(format, "Git state", GitTreeState)
7372
}
7473

75-
xprintf(format, "Built date", BuildDate)
74+
if BuildDate != unknownProperty {
75+
xprintf(format, "Built date", BuildDate)
76+
}
77+
7678
if BuildComments != unknownProperty {
7779
xprintf(format, "Built comments", BuildComments)
7880
}

0 commit comments

Comments
 (0)