Skip to content

Commit

Permalink
Refactor(debug): simplify version string (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu authored Jul 22, 2024
1 parent dd791e5 commit 24b8cdd
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 22 deletions.
7 changes: 0 additions & 7 deletions internal/version/debug.go

This file was deleted.

15 changes: 1 addition & 14 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion restapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}

0 comments on commit 24b8cdd

Please sign in to comment.