chore: initialize the Go module and repository scaffolding
Add the Go module definition and lockfile, editor and ignore rules, and a Makefile with build, test, vet, install, and man targets. The version is injected at build time with -ldflags.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
BINARY := lazyntfy
|
||||
PREFIX ?= $(HOME)/.local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
MANDIR ?= $(PREFIX)/share/man/man1
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' | grep . || echo 0.1.0)
|
||||
TOPIC ?= alerts
|
||||
|
||||
LDFLAGS := -X main.version=$(VERSION)
|
||||
|
||||
.PHONY: build install uninstall test vet fmt run man clean
|
||||
|
||||
build:
|
||||
go build -ldflags "$(LDFLAGS)" -o $(BINARY) ./cmd/lazyntfy
|
||||
|
||||
install: build
|
||||
mkdir -p "$(BINDIR)" "$(MANDIR)"
|
||||
install -m 755 $(BINARY) "$(BINDIR)/$(BINARY)"
|
||||
install -m 644 man/lazyntfy.1 "$(MANDIR)/lazyntfy.1"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(BINDIR)/$(BINARY)" "$(MANDIR)/lazyntfy.1"
|
||||
|
||||
man:
|
||||
mkdir -p "$(MANDIR)"
|
||||
install -m 644 man/lazyntfy.1 "$(MANDIR)/lazyntfy.1"
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
fmt:
|
||||
gofmt -w .
|
||||
|
||||
run: build
|
||||
./$(BINARY) $(TOPIC)
|
||||
|
||||
clean:
|
||||
rm -f $(BINARY)
|
||||
Reference in New Issue
Block a user