-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
version and revision included in config response
- Loading branch information
1 parent
98db3a7
commit a4e1e10
Showing
2 changed files
with
33 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 |
---|---|---|
@@ -1,3 +1,31 @@ | ||
package version | ||
|
||
import ( | ||
"runtime/debug" | ||
) | ||
|
||
const Version = "0.2.0" | ||
|
||
// GetVersion returns | ||
// the version number | ||
func GetVersion() string { | ||
return Version | ||
} | ||
|
||
// GetShortRevision returns a short | ||
// commit or checkout revision | ||
// from build information | ||
func GetShortRevision() string { | ||
if info, ok := debug.ReadBuildInfo(); ok { | ||
for _, setting := range info.Settings { | ||
if setting.Key == "vcs.revision" { | ||
var shortRevision string | ||
if len(setting.Value) > 7 { | ||
shortRevision = setting.Value[:7] | ||
} | ||
return shortRevision | ||
} | ||
} | ||
} | ||
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