test
This commit is contained in:
@@ -6,25 +6,25 @@ import (
|
||||
)
|
||||
|
||||
type toolClientVersion struct {
|
||||
GitVersion string `json:"gitVersion"`
|
||||
GitVersion string `json:"gitVersion"`
|
||||
}
|
||||
|
||||
type toolVersion struct {
|
||||
ClientVersion toolClientVersion `json:"clientVersion"`
|
||||
ClientVersion toolClientVersion `json:"clientVersion"`
|
||||
}
|
||||
|
||||
func Version(path string) (string, error) {
|
||||
|
||||
cmd := exec.Command(path, "version", "-o", "json", "--client=true")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
cmd := exec.Command(path, "version", "-o", "json", "--client=true")
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var objmap toolVersion
|
||||
var objmap toolVersion
|
||||
|
||||
json.Unmarshal(stdout, &objmap)
|
||||
json.Unmarshal(stdout, &objmap)
|
||||
res := objmap.ClientVersion.GitVersion
|
||||
|
||||
return res, nil
|
||||
|
Reference in New Issue
Block a user