neko/server/neko.go

70 lines
1.3 KiB
Go
Raw Permalink Normal View History

package neko
import (
"fmt"
"runtime"
2022-07-05 05:14:52 +12:00
"strings"
)
const Header = `&34
_ __ __
/ | / /__ / /______ \ /\
/ |/ / _ \/ //_/ __ \ ) ( ')
/ /| / __/ ,< / /_/ / ( / )
/_/ |_/\___/_/|_|\____/ \(__)|
2022-07-05 05:14:52 +12:00
&1&37 nurdism/m1k1o &33%s %s&0
`
var (
//
buildDate = "dev"
//
gitCommit = "dev"
//
gitBranch = "dev"
2022-07-05 05:14:52 +12:00
//
gitTag = "dev"
)
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),
}
2022-01-17 08:35:57 +13:00
type version struct {
GitCommit string
GitBranch string
2022-07-05 05:14:52 +12:00
GitTag string
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)
}
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()),
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),
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"
}