-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move version.go out of main and use BuildInfo.
Move version.go from main to the router module (lib/) so that it can (later) be accessed from Router itself. Make it use standard debug.BuildInfo that the Go toolchain produced automatically, so we no longer have to mess about with shell scripts and linker flags. This eliminates some unnecessary differences between the Dockerfile and Makefile builds.
- Loading branch information
Showing
7 changed files
with
80 additions
and
41 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.git | ||
.gitignore | ||
Dockerfile | ||
README.md | ||
docs | ||
integration_tests | ||
# | ||
# Only files that are untracked by Git should be added here. | ||
# | ||
# The builder container needs to see a pristine checkout, otherwise | ||
# vcs.modified in the BuildInfo will always be true, i.e. the build will always | ||
# be marked as "dirty". | ||
# | ||
/router |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
router | ||
/router | ||
__build |
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
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
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,42 @@ | ||
package router | ||
|
||
import ( | ||
"fmt" | ||
"runtime/debug" | ||
) | ||
|
||
// VersionInfo returns human-readable version information in a format suitable | ||
// for concatenation with other messages. | ||
func VersionInfo() (v string) { | ||
v = "(version info unavailable)" | ||
|
||
bi, ok := debug.ReadBuildInfo() | ||
if !ok { | ||
return | ||
} | ||
|
||
rev, commitTime, dirty := buildSettings(bi.Settings) | ||
if rev == "" { | ||
return | ||
} | ||
|
||
commitTimeOrDirty := "dirty" | ||
if dirty == "false" { | ||
commitTimeOrDirty = commitTime | ||
} | ||
return fmt.Sprintf("built from commit %.8s (%s) using %s", rev, commitTimeOrDirty, bi.GoVersion) | ||
} | ||
|
||
func buildSettings(bs []debug.BuildSetting) (rev, commitTime, dirty string) { | ||
for _, b := range bs { | ||
switch b.Key { | ||
case "vcs.modified": | ||
dirty = b.Value | ||
case "vcs.revision": | ||
rev = b.Value | ||
case "vcs.time": | ||
commitTime = b.Value | ||
} | ||
} | ||
return | ||
} |
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
This file was deleted.
Oops, something went wrong.