-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
8 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
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,43 @@ | ||
package driver | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
// These are set during build time via -ldflags | ||
var ( | ||
driverVersion string | ||
gitCommit string | ||
buildDate string | ||
) | ||
|
||
type VersionInfo struct { | ||
DriverVersion string `json:"driverVersion"` | ||
GitCommit string `json:"gitCommit"` | ||
BuildDate string `json:"buildDate"` | ||
GoVersion string `json:"goVersion"` | ||
Compiler string `json:"compiler"` | ||
Platform string `json:"platform"` | ||
} | ||
|
||
func GetVersion() VersionInfo { | ||
return VersionInfo{ | ||
DriverVersion: driverVersion, | ||
GitCommit: gitCommit, | ||
BuildDate: buildDate, | ||
GoVersion: runtime.Version(), | ||
Compiler: runtime.Compiler, | ||
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), | ||
} | ||
} | ||
|
||
func GetVersionJSON() (string, error) { | ||
info := GetVersion() | ||
marshalled, err := json.MarshalIndent(&info, "", " ") | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(marshalled), nil | ||
} |