-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script that runs go mod tidy with replace statements
- Loading branch information
1 parent
cc72dc1
commit 7a64e19
Showing
2 changed files
with
22 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2023 The Kubernetes Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
read -a modules <<< $(go list -m) | ||
read -a module_paths <<< $(go list -m -f {{.Dir}}) | ||
|
||
for i in ${!modules[@]}; do | ||
replace_path=$(realpath --relative-to=$(PWD) ${module_paths[i]}) | ||
if [ $replace_path == . ]; then | ||
continue | ||
fi | ||
go mod edit -replace=${modules[i]}=$replace_path | ||
done | ||
|
||
go mod tidy -v | ||
|
||
for i in ${!modules[@]}; do | ||
go mod edit -dropreplace=${modules[i]} | ||
done |