mirror of
https://github.com/Neur0toxine/demo-web-service-go.git
synced 2024-12-05 02:56:03 +03:00
40 lines
744 B
Makefile
40 lines
744 B
Makefile
|
SHELL = /bin/bash -o pipefail
|
||
|
export PATH := $(shell go env GOPATH)/bin:$(PATH)
|
||
|
|
||
|
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||
|
BIN_DIR=$(ROOT_DIR)/build
|
||
|
BIN=$(BIN_DIR)/app
|
||
|
|
||
|
all: clean build run
|
||
|
|
||
|
run:
|
||
|
@echo "==> Running"
|
||
|
@${BIN}
|
||
|
|
||
|
build: deps fmt
|
||
|
@echo "==> Building for prod"
|
||
|
@mkdir -p $(BIN_DIR)
|
||
|
@CGO_ENABLED=0 go build -o $(BIN) .
|
||
|
@echo $(BIN)
|
||
|
|
||
|
fmt:
|
||
|
@echo "==> Running gofmt"
|
||
|
@gofmt -l -s -w .
|
||
|
|
||
|
deps:
|
||
|
@echo "==> Installing dependencies"
|
||
|
@go mod tidy
|
||
|
@go mod vendor
|
||
|
|
||
|
.PHONY: clean
|
||
|
clean:
|
||
|
ifneq ($(wildcard $(ROOT_DIR)/vendor/.*),)
|
||
|
@rm -rf ./vendor
|
||
|
@mkdir ./vendor
|
||
|
@touch ./vendor/.gitkeep
|
||
|
endif
|
||
|
@rm -rf coverage.out test-report.{txt,xml}
|
||
|
@rm -rf $(BIN_DIR)
|
||
|
@mkdir -p $(BIN_DIR)
|
||
|
@touch $(BIN_DIR)/.gitkeep
|