-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: setup build-info package and env variables in Makefile
- Loading branch information
Showing
2 changed files
with
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package buildinfo | ||
|
||
import ( | ||
"runtime" | ||
) | ||
|
||
var ( | ||
Version string | ||
Revision string | ||
Branch string | ||
BuildUser string | ||
BuildDate string | ||
GoVersion = runtime.Version() | ||
) | ||
|
||
type BuildInfo struct { | ||
Version string | ||
Revision string | ||
Branch string | ||
BuildUser string | ||
BuildDate string | ||
GoVersion string | ||
} | ||
|
||
// NewDefaultBuildInfo returns the build information obtained from ldflags | ||
func NewDefaultBuildInfo() BuildInfo { | ||
return NewBuildInfo(Version, Branch, BuildDate, BuildUser, GoVersion, Revision) | ||
} | ||
|
||
// NewBuildInfo returns an object with the build information | ||
func NewBuildInfo(version, branch, buildDate, buildUser, goVersion, revision string) BuildInfo { | ||
return BuildInfo{ | ||
Version: version, | ||
Branch: branch, | ||
BuildDate: buildDate, | ||
BuildUser: buildUser, | ||
GoVersion: goVersion, | ||
Revision: revision, | ||
} | ||
} |