Chore: minor refactor

This commit is contained in:
xjasonlyu
2022-03-26 15:36:55 +08:00
parent 7ac97016fe
commit 531125ee1f
3 changed files with 10 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
//go:build debug
package version package version
var _debug = false func init() {
_debug = true
func Debug() bool {
return _debug
} }

View File

@@ -1,7 +0,0 @@
//go:build debug
package version
func init() {
_debug = true
}

View File

@@ -9,6 +9,8 @@ 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
@@ -22,6 +24,10 @@ func versionize(s string) string {
return strings.TrimPrefix(s, "v") return strings.TrimPrefix(s, "v")
} }
func Debug() bool {
return _debug
}
func String() string { func String() string {
if !Debug() { if !Debug() {
return fmt.Sprintf("%s-%s", Name, versionize(Version)) return fmt.Sprintf("%s-%s", Name, versionize(Version))