Skip to content

Instantly share code, notes, and snippets.

@bardic
Created August 12, 2023 18:18
Show Gist options
  • Select an option

  • Save bardic/96ffa78ff7f45a8a071acac1bcacb92e to your computer and use it in GitHub Desktop.

Select an option

Save bardic/96ffa78ff7f45a8a071acac1bcacb92e to your computer and use it in GitHub Desktop.
Simple shell script to loop through your go.work and tidy the known modules
#!/bin/sh
ROOT=`pwd`
while read p; do
all=$(echo $p)
first=${all%% *}
if [[ $first == "use" ]]; then
last=${all##* }
cd $last
go mod tidy
cd $ROOT
fi
done <go.work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment