github.com/cosmos/cosmos-sdk@v0.50.10/scripts/go-update-dep-all.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -euo pipefail
     4  
     5  if [ -z ${1+x} ]; then
     6    echo "USAGE:
     7      ./scripts/go-update-dep-all.sh <go-mod-dependency>
     8    This command updates a dependency in all of the go.mod files which import it.
     9    It should be called with a single argument which is the go module path of the dependency,
    10    with an optional version specified by @."
    11    exit
    12  fi
    13  
    14  dependency=$1
    15  # in case the user explicitly specified a dependency version with @, we separate
    16  # the dependency module name into dependency_mod
    17  IFS='@' read -ra dependency_mod <<< "$dependency"
    18  dependency_mod=${dependency_mod[0]}
    19  
    20  for modfile in $(find . -name go.mod); do
    21    if grep $dependency_mod $modfile &> /dev/null; then
    22      echo "Updating $modfile"
    23      DIR=$(dirname $modfile)
    24      # we want to skip the go.mod of the package we're updating
    25      if [[ "$dependency_mod" == *"$(basename $DIR)"  ]]; then
    26          echo "Skipping $DIR"
    27          continue
    28      fi
    29       (cd $DIR; go get -u $dependency)
    30    fi
    31  done