Skip to content

Commit

Permalink
Makefile: clean go build cache (#17079)
Browse files Browse the repository at this point in the history
  • Loading branch information
hqueue authored and fjl committed Jul 24, 2018
1 parent 894022a commit ae674a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
10 changes: 10 additions & 0 deletions build/clean_go_build_cache.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ae674a3

Please sign in to comment.