make集成go语言项目

参考下面这个 makefile

.PHONY: build debug dlv clean tool lint help

all: build

build:
	@go build -v .

debug:
	go build -gcflags "all=-N -l" -v -o app .

dlv:
	dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./app

tool:
	go vet ./...; true
	gofmt -w .

lint:
	golint ./...

clean:
	rm -rf go-gin-example
	go clean -i .

help:
	@echo "make: compile packages and dependencies"
	@echo "make tool: run specified go tool"
	@echo "make lint: golint ./..."
	@echo "make clean: remove object files and cached files"

makefile中的命令加上 at符号之后 @ 不会打印命令到标准输出;

可以配合make来实现
使用以上的makefile, 使用dlv则会运行命令:
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./app

posted @ 2024-02-26 13:17  潜行1  阅读(36)  评论(0)    收藏  举报