-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update go.mod to specify the module is go1.14 #866
Changes from all commits
3e02821
f542d4a
0628e44
5db2cbe
461850b
8a5fe34
926681d
43644de
47eff26
885bceb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ replace ( | |
k8s.io/code-generator => k8s.io/code-generator v0.16.4 | ||
) | ||
|
||
go 1.13 | ||
go 1.14 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
|
||
set -o pipefail | ||
|
||
[[ ! -v REPO_ROOT_DIR ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" | ||
readonly REPO_ROOT_DIR | ||
|
||
source_dirs="cmd pkg test lib" | ||
|
||
# Store for later | ||
|
@@ -110,21 +113,38 @@ go_fmt() { | |
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w | ||
} | ||
|
||
# Run a go tool, installing it first if necessary. | ||
# Parameters: $1 - tool package/dir for go get/install. | ||
# $2 - tool to run. | ||
# $3..$n - parameters passed to the tool. | ||
run_go_tool() { | ||
local tool=$2 | ||
local install_failed=0 | ||
if [[ -z "$(which ${tool})" ]]; then | ||
local action=get | ||
[[ $1 =~ ^[\./].* ]] && action=install | ||
# Avoid running `go get` from root dir of the repository, as it can change go.sum and go.mod files. | ||
# See discussions in https://github.com/golang/go/issues/27643. | ||
if [[ ${action} == "get" && $(pwd) == "${REPO_ROOT_DIR}" ]]; then | ||
local temp_dir="$(mktemp -d)" | ||
# Swallow the output as we are returning the stdout in the end. | ||
pushd "${temp_dir}" > /dev/null 2>&1 | ||
GOFLAGS="" go ${action} "$1" || install_failed=1 | ||
popd > /dev/null 2>&1 | ||
else | ||
GOFLAGS="" go ${action} "$1" || install_failed=1 | ||
fi | ||
fi | ||
(( install_failed )) && return ${install_failed} | ||
shift 2 | ||
${tool} "$@" | ||
} | ||
|
||
|
||
source_format() { | ||
set +e | ||
which goimports >/dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
echo "✋ No 'goimports' found. Please use" | ||
echo "✋ go install golang.org/x/tools/cmd/goimports" | ||
echo "✋ to enable import cleanup. Import cleanup skipped." | ||
|
||
# Run go fmt instead | ||
go_fmt | ||
else | ||
echo "🧽 ${X}Format" | ||
goimports -w $(echo $source_dirs) | ||
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w | ||
fi | ||
run_go_tool golang.org/x/tools/cmd/goimports goimports -w $(echo $source_dirs) | ||
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w | ||
set -e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my former comment about using run_go_tool as I haven't known that the test-infra scripts are not running on the stock bash of macOS. However, I wonder whether we could inline the And even is |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dprotaso It's that -v which does not work in bash v3
No worries, I'll fix that tomorrowday after tomorrow, sorry.