mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 09:16:58 +08:00
Refactor(debug): simplify version string (#380)
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
//go:build debug
|
||||
|
||||
package version
|
||||
|
||||
func init() {
|
||||
_debug = true
|
||||
}
|
@@ -9,8 +9,6 @@ import (
|
||||
const Name = "tun2socks"
|
||||
|
||||
var (
|
||||
_debug = false
|
||||
|
||||
// Version can be set at link time by executing
|
||||
// the command: `git describe --abbrev=0 --tags HEAD`
|
||||
Version string
|
||||
@@ -20,19 +18,8 @@ var (
|
||||
GitCommit string
|
||||
)
|
||||
|
||||
func versionize(s string) string {
|
||||
return strings.TrimPrefix(s, "v")
|
||||
}
|
||||
|
||||
func Debug() bool {
|
||||
return _debug
|
||||
}
|
||||
|
||||
func String() string {
|
||||
if !Debug() {
|
||||
return fmt.Sprintf("%s-%s", Name, versionize(Version))
|
||||
}
|
||||
return fmt.Sprintf("%s-%s (debug)", Name, versionize(Version))
|
||||
return fmt.Sprintf("%s-%s", Name, strings.TrimPrefix(Version, "v"))
|
||||
}
|
||||
|
||||
func BuildString() string {
|
||||
|
@@ -210,7 +210,6 @@ func version(w http.ResponseWriter, r *http.Request) {
|
||||
render.JSON(w, r, render.M{
|
||||
"version": V.Version,
|
||||
"commit": V.GitCommit,
|
||||
"debug": V.Debug(),
|
||||
"modules": V.Info(),
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user