~elektito/hodhod

b98038c6f854fb9a9cf8d5f90fcca2b180987528 — Mostafa Razavi 1 year, 2 months ago 2840dbb v0.1.0
Add a -version flag
2 files changed, 9 insertions(+), 1 deletions(-)

M Makefile
M main.go
M Makefile => Makefile +1 -1
@@ 4,7 4,7 @@ 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 build -o $(BINDIR) $(FLAGS)

M main.go => main.go +8 -0
@@ 26,6 26,8 @@ const (
	GeminiMaxRequestSize = 1024
)

var Version = "unknown"

type ErrNotFound struct {
	Reason string
	Url    string


@@ 227,8 229,14 @@ func loadCertificates(cfg *hodhod.Config) (certs []tls.Certificate, err error) {

func main() {
	configFile := flag.String("config", "config.json", "Path to config file")
	showVersion := flag.Bool("version", false, "Print hodhod version")
	flag.Parse()

	if *showVersion {
		fmt.Println("Hodhod version:", Version)
		os.Exit(0)
	}

	cfg, err := hodhod.LoadConfig(*configFile)
	if err != nil {
		fail("loading config", err)