2020-10-23 03:54:50 +13:00
|
|
|
package neko
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
2022-07-05 05:14:52 +12:00
|
|
|
"strings"
|
2020-10-23 03:54:50 +13:00
|
|
|
)
|
|
|
|
|
|
|
|
const Header = `&34
|
|
|
|
_ __ __
|
|
|
|
/ | / /__ / /______ \ /\
|
|
|
|
/ |/ / _ \/ //_/ __ \ ) ( ')
|
|
|
|
/ /| / __/ ,< / /_/ / ( / )
|
|
|
|
/_/ |_/\___/_/|_|\____/ \(__)|
|
2022-07-05 05:14:52 +12:00
|
|
|
&1&37 nurdism/m1k1o &33%s %s&0
|
2020-10-23 03:54:50 +13:00
|
|
|
`
|
|
|
|
|
|
|
|
var (
|
|
|
|
//
|
|
|
|
buildDate = "dev"
|
|
|
|
//
|
|
|
|
gitCommit = "dev"
|
|
|
|
//
|
|
|
|
gitBranch = "dev"
|
2022-07-05 05:14:52 +12:00
|
|
|
//
|
|
|
|
gitTag = "dev"
|
2020-10-23 03:54:50 +13:00
|
|
|
)
|
|
|
|
|
2022-01-17 08:35:57 +13:00
|
|
|
var Version = &version{
|
|
|
|
GitCommit: gitCommit,
|
|
|
|
GitBranch: gitBranch,
|
2022-07-05 05:14:52 +12:00
|
|
|
GitTag: gitTag,
|
2022-01-17 08:35:57 +13:00
|
|
|
BuildDate: buildDate,
|
|
|
|
GoVersion: runtime.Version(),
|
|
|
|
Compiler: runtime.Compiler,
|
|
|
|
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|
|
|
|
|
2022-01-17 08:35:57 +13:00
|
|
|
type version struct {
|
2020-10-23 03:54:50 +13:00
|
|
|
GitCommit string
|
|
|
|
GitBranch string
|
2022-07-05 05:14:52 +12:00
|
|
|
GitTag string
|
2020-10-23 03:54:50 +13:00
|
|
|
BuildDate string
|
|
|
|
GoVersion string
|
|
|
|
Compiler string
|
|
|
|
Platform string
|
|
|
|
}
|
|
|
|
|
2022-01-17 08:35:57 +13:00
|
|
|
func (i *version) String() string {
|
2022-07-05 05:14:52 +12:00
|
|
|
version := i.GitTag
|
|
|
|
if version == "" || version == "dev" {
|
|
|
|
version = i.GitBranch
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s@%s", version, i.GitCommit)
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|
|
|
|
|
2022-01-17 08:35:57 +13:00
|
|
|
func (i *version) Details() string {
|
2022-07-05 05:14:52 +12:00
|
|
|
return "\n" + strings.Join([]string{
|
|
|
|
fmt.Sprintf("Version %s", i.String()),
|
2020-10-23 03:54:50 +13:00
|
|
|
fmt.Sprintf("GitCommit %s", i.GitCommit),
|
|
|
|
fmt.Sprintf("GitBranch %s", i.GitBranch),
|
2022-07-05 05:14:52 +12:00
|
|
|
fmt.Sprintf("GitTag %s", i.GitTag),
|
2020-10-23 03:54:50 +13:00
|
|
|
fmt.Sprintf("BuildDate %s", i.BuildDate),
|
|
|
|
fmt.Sprintf("GoVersion %s", i.GoVersion),
|
|
|
|
fmt.Sprintf("Compiler %s", i.Compiler),
|
|
|
|
fmt.Sprintf("Platform %s", i.Platform),
|
2022-07-05 05:14:52 +12:00
|
|
|
}, "\n") + "\n"
|
2020-10-23 03:54:50 +13:00
|
|
|
}
|