mirror of https://github.com/knative/client.git
fix: Use go_run from common lib (#1793)
* fix: Use go_run from common lib * chore: Set Bash options in name format * Reflect shell suggestion for the direct changes
This commit is contained in:
parent
8c648379a4
commit
189592606e
|
|
@ -15,6 +15,8 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
source_dirs="cmd pkg test lib tools"
|
source_dirs="cmd pkg test lib tools"
|
||||||
|
|
||||||
|
|
@ -25,7 +27,9 @@ else
|
||||||
ARGS=("$@")
|
ARGS=("$@")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -eu
|
# Tool version
|
||||||
|
readonly GOIMPORTS_VERSION="v0.7.0"
|
||||||
|
readonly GOLINT_VERSION="v1.52.0"
|
||||||
|
|
||||||
# Run build
|
# Run build
|
||||||
run() {
|
run() {
|
||||||
|
|
@ -110,19 +114,19 @@ codegen() {
|
||||||
|
|
||||||
go_fmt() {
|
go_fmt() {
|
||||||
echo "🧹 ${S}Format"
|
echo "🧹 ${S}Format"
|
||||||
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
|
find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
|
||||||
}
|
}
|
||||||
|
|
||||||
source_format() {
|
source_format() {
|
||||||
set +e
|
set +e
|
||||||
run_go_tool golang.org/x/tools/cmd/goimports goimports -w $(echo $source_dirs)
|
go_run "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}" -w $(echo "$source_dirs")
|
||||||
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
|
find $(echo "$source_dirs") -name "*.go" -print0 | xargs -0 gofmt -s -w
|
||||||
set -e
|
set -e
|
||||||
}
|
}
|
||||||
|
|
||||||
source_lint() {
|
source_lint() {
|
||||||
echo "🔍 Lint"
|
echo "🔍 Lint"
|
||||||
run_go_tool github.com/golangci/golangci-lint/cmd/golangci-lint golangci-lint run || \
|
go_run "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLINT_VERSION}" run || \
|
||||||
{ echo "--- FAIL: golangci-lint failed please fix the reported errors"; return 1; }
|
{ echo "--- FAIL: golangci-lint failed please fix the reported errors"; return 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue