Skip to content

Instantly share code, notes, and snippets.

@whitekid
Last active March 21, 2022 00:45
Show Gist options
  • Save whitekid/0d337b36901ab3130ea60c433e2f0351 to your computer and use it in GitHub Desktop.
Save whitekid/0d337b36901ab3130ea60c433e2f0351 to your computer and use it in GitHub Desktop.
TARGET=bin/<your-target>
GO_PKG=<your-module-name>
SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "*_test.go")
GO?=go
BUILD_FLAGS?=-v
.PHONY: clean test dep tidy
all: build
build: $(TARGET)
$(TARGET): $(SRC)
@mkdir -p ${TARGET}
${GO} build -o bin/ ${BUILD_FLAGS} ./cmd/...
clean:
rm -f ${TARGET}
test:
${GO} test ./... --count=1
# update modules & tidy
dep:
rm -f go.mod go.sum
${GO} mod init ${GO_PKG}
@$(MAKE) tidy
tidy:
${GO} mod tidy
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment