~elektito/hodhod

2ab01205882a02a87485cdad06da42d3858a16a0 — Mostafa Razavi 5 months ago bfce1d9
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.
2 files changed, 2 insertions(+), 13 deletions(-)

M Makefile
M main.go
M Makefile => Makefile +1 -2
@@ 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)

M main.go => main.go +1 -11
@@ 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()