Makefile 937 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Targets:
  2. #
  3. # all: Builds the code locally after testing
  4. #
  5. # fmt: Formats the source files
  6. # build: Builds the code locally
  7. # vet: Vets the code
  8. # lint: Runs lint over the code (you do not need to fix everything)
  9. # test: Runs the tests
  10. # cover: Gives you the URL to a nice test coverage report
  11. #
  12. # install: Builds, tests and installs the code locally
  13. .PHONY: all fmt build vet lint test cover install
  14. # The first target is always the default action if `make` is called without
  15. # args we build and install into $GOPATH so that it can just be run
  16. all: fmt vet test install
  17. fmt:
  18. @gofmt -s -w ./$*
  19. build:
  20. @go build
  21. vet:
  22. @go vet *.go
  23. lint:
  24. @golint *.go
  25. test:
  26. @go test -v ./...
  27. cover: COVERAGE_FILE := coverage.out
  28. cover:
  29. @go test -coverprofile=$(COVERAGE_FILE) && \
  30. cover -html=$(COVERAGE_FILE) && rm $(COVERAGE_FILE)
  31. install:
  32. @go install ./...