From 531125ee1f5678dbacef60b121e1719d4e0ceccc Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Sat, 26 Mar 2022 15:36:55 +0800 Subject: [PATCH] Chore: minor refactor --- internal/version/debug.go | 8 ++++---- internal/version/debug_on.go | 7 ------- internal/version/version.go | 6 ++++++ 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 internal/version/debug_on.go diff --git a/internal/version/debug.go b/internal/version/debug.go index 708057b..a2c3afa 100644 --- a/internal/version/debug.go +++ b/internal/version/debug.go @@ -1,7 +1,7 @@ -package version +//go:build debug -var _debug = false +package version -func Debug() bool { - return _debug +func init() { + _debug = true } diff --git a/internal/version/debug_on.go b/internal/version/debug_on.go deleted file mode 100644 index a2c3afa..0000000 --- a/internal/version/debug_on.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build debug - -package version - -func init() { - _debug = true -} diff --git a/internal/version/version.go b/internal/version/version.go index 443fae0..3bb92ae 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -9,6 +9,8 @@ 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 @@ -22,6 +24,10 @@ 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))