From 219288c98477e392242e5dcca300d20062b3c670 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Sat, 7 Dec 2019 13:36:14 -0800 Subject: Set version at build time --- Makefile | 2 +- main.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d629150..7a77930 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ IMAGE="docker.crute.me/websocket-proxy" VERSION="0.1.0" websocket-proxy: main.go sockets.go server.go client.go - CGO_ENABLED=0 go build -o $@ $^ + CGO_ENABLED=0 go build -ldflags "-X main.version=$(VERSION)" -o $@ $^ .PHONY: docker docker: websocket-proxy diff --git a/main.go b/main.go index 75555e6..ec4170b 100644 --- a/main.go +++ b/main.go @@ -11,9 +11,11 @@ import ( "github.com/spf13/cobra" ) +var version string + var rootCmd = &cobra.Command{ Use: "websocket-proxy", - Version: "0.1.0", + Version: version, Short: "Proxy TCP connections over a websocket", } -- cgit v1.2.3