Makefile: clean go build cache (#17079)

This commit is contained in:
Hyung-Kyu Hqueue Choi 2018-07-24 09:11:51 +09:00 committed by Felix Lange
parent 894022a3d5
commit ae674a3660
2 changed files with 11 additions and 0 deletions

View File

@ -41,6 +41,7 @@ lint: ## Run linters.
build/env.sh go run build/ci.go lint
clean:
./build/clean_go_build_cache.sh
rm -fr build/_workspace/pkg/ $(GOBIN)/*
# The devtools target installs tools required for 'go generate'.

10
build/clean_go_build_cache.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
golang_version=$(go version |cut -d' ' -f3 |sed 's/go//')
# Clean go build cache when go version is greater than or equal to 1.10
if !(version_gt 1.10 $golang_version); then
go clean -cache
fi