Skip to content

Commit ae674a3

Browse files
hqueuefjl
authored andcommitted
Makefile: clean go build cache (#17079)
1 parent 894022a commit ae674a3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ lint: ## Run linters.
4141
build/env.sh go run build/ci.go lint
4242

4343
clean:
44+
./build/clean_go_build_cache.sh
4445
rm -fr build/_workspace/pkg/ $(GOBIN)/*
4546

4647
# The devtools target installs tools required for 'go generate'.

build/clean_go_build_cache.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
4+
5+
golang_version=$(go version |cut -d' ' -f3 |sed 's/go//')
6+
7+
# Clean go build cache when go version is greater than or equal to 1.10
8+
if !(version_gt 1.10 $golang_version); then
9+
go clean -cache
10+
fi

0 commit comments

Comments
 (0)