This is my boilerplate for a Go http server project. Feedback and suggestions are encouraged!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.1KB

  1. ARCH := $(shell uname -m)
  2. VERSION := $(shell git describe --always --dirty=-dirty)
  3. FN := http
  4. UNAME_S := $(shell uname -s)
  5. GOLDFLAGS += -X main.Version=$(VERSION)
  6. GOLDFLAGS += -X main.Buildarch=$(ARCH)
  7. GOFLAGS := -ldflags "$(GOLDFLAGS)"
  8. default: debug
  9. commit: fmt lint
  10. git commit -a
  11. # get golangci-lint with:
  12. # go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0
  13. # get gofumports with:
  14. # go get mvdan.cc/gofumpt/gofumports
  15. fmt:
  16. gofumports -l -w .
  17. golangci-lint run --fix
  18. lint:
  19. golangci-lint run
  20. sh -c 'test -z "$$(gofmt -l .)"'
  21. debug: ./$(FN)d
  22. DEBUG=1 GOTRACEBACK=all ./$(FN)d
  23. debugger:
  24. cd cmd/$(FN)d && dlv debug main.go
  25. run: ./$(FN)d
  26. ./$(FN)d
  27. clean:
  28. -rm -f ./$(FN)d debug.log
  29. docker:
  30. docker build --progress plain .
  31. ./$(FN)d: cmd/$(FN)d/main.go */*.go
  32. cd httpserver && \
  33. cd ../cmd/$(FN)d && \
  34. go build -o ../../$(FN)d $(GOFLAGS) . && \
  35. cd ../.. && \
  36. rice append -i ./httpserver --exec ./httpd
  37. tools: rice-install
  38. go get -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0
  39. go get -v mvdan.cc/gofumpt/gofumports
  40. rice-install:
  41. go get -v github.com/GeertJohan/go.rice/rice