forked from root-gg/plik
-
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.
- Loading branch information
Charles-Antoine Mathieu
committed
Sep 28, 2020
1 parent
afe2a8c
commit 046f403
Showing
7 changed files
with
152 additions
and
127 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 |
---|---|---|
|
@@ -9,7 +9,6 @@ webapp/dist | |
clients | ||
client/client | ||
servers | ||
server/common/version.go | ||
release | ||
releases | ||
debs | ||
|
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,94 @@ | ||
package common | ||
|
||
// | ||
// This file is generated automatically by gen_build_info.sh | ||
// | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
"time" | ||
) | ||
|
||
var buildInfoString string | ||
var buildInfo *BuildInfo | ||
|
||
func init() { | ||
buildInfo = &BuildInfo{} | ||
|
||
if buildInfoString != "" { | ||
jsonString, err := base64.StdEncoding.DecodeString(buildInfoString) | ||
if err != nil { | ||
panic(fmt.Errorf("Unable to parse build info base64 string : %s", err)) | ||
} | ||
|
||
err = json.Unmarshal(jsonString, buildInfo) | ||
if err != nil { | ||
panic(fmt.Errorf("Unable to parse build info json string : %s", err)) | ||
} | ||
} | ||
} | ||
|
||
// BuildInfo export build related variables | ||
type BuildInfo struct { | ||
Version string `json:"version"` | ||
Date int64 `json:"date"` | ||
|
||
User string `json:"user"` | ||
Host string `json:"host"` | ||
|
||
GitShortRevision string `json:"gitShortRevision"` | ||
GitFullRevision string `json:"gitFullRevision"` | ||
|
||
IsRelease bool `json:"isRelease"` | ||
IsMint bool `json:"isMint"` | ||
|
||
GoVersion string `json:"goVersion"` | ||
|
||
Clients []*Client `json:"clients"` | ||
Releases []*Release `json:"releases"` | ||
} | ||
|
||
// Client export client build related variables | ||
type Client struct { | ||
Name string `json:"name"` | ||
Md5 string `json:"md5"` | ||
Path string `json:"path"` | ||
OS string `json:"os"` | ||
ARCH string `json:"arch"` | ||
} | ||
|
||
// Release export releases related variables | ||
type Release struct { | ||
Name string `json:"name"` | ||
Date int64 `json:"date"` | ||
} | ||
|
||
// GetBuildInfo get build info | ||
func GetBuildInfo() *BuildInfo { | ||
return buildInfo | ||
} | ||
|
||
func (bi *BuildInfo) String() string { | ||
|
||
v := fmt.Sprintf("v%s (built from git rev %s", bi.Version, bi.GitShortRevision) | ||
|
||
// Compute flags | ||
var flags []string | ||
if buildInfo.IsMint { | ||
flags = append(flags, "mint") | ||
} | ||
if buildInfo.IsRelease { | ||
flags = append(flags, "release") | ||
} | ||
|
||
if len(flags) > 0 { | ||
v += fmt.Sprintf(" [%s]", strings.Join(flags, ",")) | ||
} | ||
|
||
v += fmt.Sprintf(" at %s with %s)", time.Unix(bi.Date, 0), bi.GoVersion) | ||
|
||
return v | ||
} |
Oops, something went wrong.