-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bbolt command line version flag to get runtime information.
Signed-off-by: Ishan Tyagi <[email protected]>
- Loading branch information
1 parent
b7798fd
commit 1244ce2
Showing
3 changed files
with
81 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
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,33 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"runtime" | ||
"strings" | ||
) | ||
|
||
var ( | ||
// Version shows the last bbolt binary version released. | ||
Version = "1.3.7" | ||
) | ||
|
||
// PrintVersionInfo prints the information regrading version. | ||
func PrintVersionInfo() string { | ||
return fmt.Sprintf( | ||
"bbolt version: %s \nGit SHA: %s \nGo Version: %s \nGo OS/Arch: %s/%s", | ||
Version, getGitSHA(), runtime.Version(), runtime.GOOS, runtime.GOARCH, | ||
) | ||
} | ||
|
||
// getGitSHA returns the bbolt code commit SHA on git. | ||
func getGitSHA() string { | ||
cmd := exec.Command("git", "rev-parse", "HEAD") | ||
output, err := cmd.Output() | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
commitSHA := strings.TrimSpace(string(output)) | ||
return commitSHA[:10] | ||
} |