From 8c73e866941f0dadee9801e70c14e2e5f7d9c949 Mon Sep 17 00:00:00 2001 From: Jin Dong Date: Mon, 30 Dec 2024 15:13:25 +0000 Subject: [PATCH] add script to tidy all modules Signed-off-by: Jin Dong --- Makefile | 4 ++++ scripts/go-mod-tidy | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 scripts/go-mod-tidy diff --git a/Makefile b/Makefile index 61c88c83..0f41ab08 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,10 @@ build-plugins: $(PLUGINS) build-check: $(Q)$(GO_BUILD) -v $(GO_MODULES) +mod-tidy: + $(Q)$(GO_CMD) mod tidy + $(Q)./scripts/go-mod-tidy + # # clean targets # diff --git a/scripts/go-mod-tidy b/scripts/go-mod-tidy new file mode 100755 index 00000000..adb055e7 --- /dev/null +++ b/scripts/go-mod-tidy @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright The containerd Authors. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Run go mod tidy in all go modules +# +set -eu -o pipefail + +find . -name go.mod | while read -r gomod; do + dir=$(dirname "$gomod") + + pushd "$dir" + go mod tidy + popd +done