This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add buildinfo package to hold ldflags info
- Loading branch information
1 parent
b4db778
commit 79afd53
Showing
1 changed file
with
40 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package buildinfo | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
// VersionInfo describes structure of version information objects. | ||
type VersionInfo struct { | ||
Version string | ||
Commit string | ||
Date string | ||
} | ||
|
||
var ( | ||
version = "development" | ||
commit = "na" | ||
date = time.Now().Local().Format(time.ANSIC) | ||
|
||
// Version provides access to version info and related printing functions. | ||
Version *VersionInfo | ||
) | ||
|
||
func init() { | ||
Version = &VersionInfo{ | ||
Version: version, | ||
Commit: commit, | ||
Date: date, | ||
} | ||
} | ||
|
||
// Print prints the version information. | ||
func (v *VersionInfo) Print() { | ||
fmt.Printf("Dockma CLI version %s\n", v.Version) | ||
} | ||
|
||
// PrintFull prints the full version information including built date and last commit. | ||
func (v *VersionInfo) PrintFull() { | ||
fmt.Printf("Dockma CLI Version %s built on %s (commit: %s)\n", v.Version, v.Date, v.Commit) | ||
} |