-
Notifications
You must be signed in to change notification settings - Fork 44
Add --version flag #163
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
base: main
Are you sure you want to change the base?
Add --version flag #163
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,9 @@ import ( | |
| "tailscale.com/version" | ||
| ) | ||
|
|
||
| // version is set at build time via -ldflags "-X main.version=..." | ||
| var version = "dev" | ||
|
|
||
| // Command line flags | ||
| var ( | ||
| flagPort = flag.Int("port", envIntOr("TSIDP_PORT", 443), "port to listen on") | ||
|
|
@@ -57,6 +60,11 @@ var ( | |
| func main() { | ||
| ctx := context.Background() | ||
|
|
||
| if len(os.Args) == 2 && os.Args[1] == "--version" { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only handles the exact invocation tsidp-server --version. It silently ignores:
The idiomatic Go approach is to register it as a proper flag: |
||
| fmt.Println(version) | ||
| os.Exit(0) | ||
| } | ||
|
|
||
| flag.Parse() | ||
| switch *flagLogLevel { | ||
| case "debug": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given this imports Tailscale.com/version ... is this more a buildVersion?