From 41998b2741f762c14172ca3e03b677a0afb3892a Mon Sep 17 00:00:00 2001 From: Takumi Sueda Date: Fri, 21 Feb 2025 15:38:41 +0900 Subject: [PATCH] Embed and show version --- VERSION | 1 + main.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..1cc5f65 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.1.0 \ No newline at end of file diff --git a/main.go b/main.go index 88fff19..8c8d564 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + _ "embed" "flag" "fmt" "os" @@ -13,7 +14,12 @@ import ( "github.com/rs/zerolog/log" ) -var usage = ` +//go:embed VERSION +var version string + +var usage = fmt.Sprintf(` +tftp-now %s + Usage of tftp-now: tftp-now [] @@ -42,7 +48,7 @@ Tips: - If tftp-now executable itself or a link to tftp-now is named "tftp-now-serve", tftp-now will start a TFTP server without any explicit subcommand. Please specify a subcommand if you want to specify options. -` +`, version)[1:] func main() { os.Exit(main_())