mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 17:26: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"
|
const Name = "tun2socks"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_debug = false
|
|
||||||
|
|
||||||
// Version can be set at link time by executing
|
// Version can be set at link time by executing
|
||||||
// the command: `git describe --abbrev=0 --tags HEAD`
|
// the command: `git describe --abbrev=0 --tags HEAD`
|
||||||
Version string
|
Version string
|
||||||
@@ -20,19 +18,8 @@ var (
|
|||||||
GitCommit string
|
GitCommit string
|
||||||
)
|
)
|
||||||
|
|
||||||
func versionize(s string) string {
|
|
||||||
return strings.TrimPrefix(s, "v")
|
|
||||||
}
|
|
||||||
|
|
||||||
func Debug() bool {
|
|
||||||
return _debug
|
|
||||||
}
|
|
||||||
|
|
||||||
func String() string {
|
func String() string {
|
||||||
if !Debug() {
|
return fmt.Sprintf("%s-%s", Name, strings.TrimPrefix(Version, "v"))
|
||||||
return fmt.Sprintf("%s-%s", Name, versionize(Version))
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s-%s (debug)", Name, versionize(Version))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildString() string {
|
func BuildString() string {
|
||||||
|
@@ -210,7 +210,6 @@ func version(w http.ResponseWriter, r *http.Request) {
|
|||||||
render.JSON(w, r, render.M{
|
render.JSON(w, r, render.M{
|
||||||
"version": V.Version,
|
"version": V.Version,
|
||||||
"commit": V.GitCommit,
|
"commit": V.GitCommit,
|
||||||
"debug": V.Debug(),
|
|
||||||
"modules": V.Info(),
|
"modules": V.Info(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user