Skip to content

Commit

Permalink
goworksync: include running go mod tidy
Browse files Browse the repository at this point in the history
Find all the 'go.mod' files in the repository, then change to it's
directory and run 'go mod tidy'.  This helps us ensure that all deps
information are within the go.mod files and thus help 'go work sync'
work properly.
  • Loading branch information
sluongng committed May 28, 2022
1 parent 4bd9c8d commit c265e33
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tools/goworksync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
GOBIN=$1

(
cd $BUILD_WORKSPACE_DIRECTORY
$(bazel info execution_root)/$GOBIN work sync
cd "$BUILD_WORKSPACE_DIRECTORY" || exit
GO="$(bazel info execution_root)/$GOBIN"

find . -name go.mod |
while IFS= read -r -d '' f; do
d=$(dirname "$f")
(
cd "$d" || exit
"$GO" mod tidy
)
done

"$GO" work sync
)

0 comments on commit c265e33

Please sign in to comment.