Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/njuettner/maker
Creates a Makefile for Go projects 📂✨
https://github.com/njuettner/maker
go golang helper makefile tool
Last synced: 26 days ago
JSON representation
Creates a Makefile for Go projects 📂✨
- Host: GitHub
- URL: https://github.com/njuettner/maker
- Owner: njuettner
- License: mit
- Created: 2020-02-18T15:25:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-02T13:13:20.000Z (over 3 years ago)
- Last Synced: 2024-06-21T06:44:17.276Z (5 months ago)
- Topics: go, golang, helper, makefile, tool
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# maker
Creates Makefile for Go projects
## Usage
```console
make help
``````console
Usage:build builds a local binary
build-linux builds binary for linux/amd64
build-darwin builds binary for darwin/amd64
install install the application
run runs go run main.go
clean cleans the binary
lint runs golangci-lint
test runs go test with default values
setup setup go modules
build-docker builds docker image to registry
push-docker pushes docker image to registry
help prints this help message
```## Example Makefile:
```make
APPLICATION ?= example
REGISTRY ?= njuettner
VERSION ?= $(shell git describe --tags --always --dirty)
SOURCES = $(shell find . -name '*.go')
GOPKGS = $(shell go list ./...)
TAG ?= $(VERSION)
BUILD_FLAGS ?= -v
LDFLAGS ?= -X main.version=$(VERSION) -w -sdefault: build
.PHONY: build
## build: builds a local binary
build: clean $(SOURCES)
CGO_ENABLED=0 go build -o ${APPLICATION} $(BUILD_FLAGS) ..PHONY: build-linux
## build-linux: builds binary for linux/amd64
build-linux: clean $(SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) ..PHONY: build-darwin
## build-darwin: builds binary for darwin/amd64
build-darwin: clean $(SOURCES)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) ..PHONY: install
## install: install the application
install: $(SOURCES)
go install ..PHONY: run
## run: runs go run main.go
run: $(SOURCES)
go run -race ..PHONY: clean
## clean: cleans the binary
clean:
go clean.PHONY: lint
## lint: runs golangci-lint
lint:
golangci-lint run --timeout=10m ./....PHONY: test
## test: runs go test with default values
test:
go test -v -race -cover $(GOPKGS).PHONY: setup
## setup: setup go modules
setup:
@go mod init \
&& go mod tidy \
&& go mod vendor.PHONY: build-docker
## build-docker: builds docker image to registry
build-docker: build-linux
docker build -t ${APPLICATION}:${TAG} ..PHONY: push-docker
## push-docker: pushes docker image to registry
push-docker: build-docker
docker push ${REGISTRY}/${APPLICATION}:${TAG}.PHONY: help
## help: prints this help message
help:
@echo "Usage: \n"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
```