From 2ab01205882a02a87485cdad06da42d3858a16a0 Mon Sep 17 00:00:00 2001 From: Mostafa Razavi Date: Mon, 1 May 2023 08:25:11 +0200 Subject: [PATCH] Revert "Use go:generate to set version number" This reverts commit bfce1d9be12c36e805573ad26dc3fa5f548cd881. It did not work as I thought it might (go install still doesn't set the version correctly), so I'm reverting this to the old version. --- Makefile | 3 +-- main.go | 12 +----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 3b0f5f1..fbe1446 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,9 @@ SRC != find . -name '*.go' ! -name '*_test.go' # Force using go's builtin dns resolver, instead of the system one, in order to # produce a nice, clean, statically-linked executable! -FLAGS = -tags netgo +FLAGS = -tags netgo -ldflags="-X main.Version=$(shell git describe --always --dirty --tags)" $(BINDIR)/$(NAME): $(SRC) - go generate go build -o $(BINDIR) $(FLAGS) all: $(NAME) diff --git a/main.go b/main.go index a9df46e..a594bec 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "bufio" "crypto/tls" "crypto/x509" - _ "embed" "errors" "flag" "fmt" @@ -14,7 +13,6 @@ import ( "net/url" "os" "path" - "strings" "sync" "time" @@ -28,9 +26,7 @@ const ( GeminiMaxRequestSize = 1024 ) -//go:generate sh -c "git describe --always --dirty --tags | xargs >version.txt" -//go:embed version.txt -var Version string +var Version = "unknown" type ErrNotFound struct { Reason string @@ -232,12 +228,6 @@ func loadCertificates(cfg *hodhod.Config) (certs []tls.Certificate, err error) { } func main() { - if Version == "" { - Version = "unknown" - } else { - Version = strings.TrimSpace(Version) - } - configFile := flag.String("config", "config.json", "Path to config file") showVersion := flag.Bool("version", false, "Print hodhod version") flag.Parse() -- 2.38.5