Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor(debug): simplify version string #380

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
})
}
Loading