Russ Cox | bccf9cd | 2024-08-12 10:46:38 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2024 The Go Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style |
| 4 | # license that can be found in the LICENSE file. |
| 5 | |
| 6 | # Run worksync.sh to sync the various go.work, go.work.sum, go.mod, and go.sum files |
| 7 | # after changing dependencies. |
| 8 | |
| 9 | set -e |
| 10 | |
| 11 | syncmod() { |
| 12 | dir=$1 |
| 13 | oscars=$(GOWORK=off go -C $dir list -m ... | awk 'NR>1 && /^golang.org\/x\/oscar/ { print $1 "@master" }') |
| 14 | if [ "$oscars" != "" ]; then |
| 15 | go -C $dir get $oscars |
| 16 | fi |
| 17 | } |
| 18 | |
| 19 | tidymod() { |
| 20 | dir=$1 |
| 21 | go -C $dir mod tidy |
| 22 | } |
| 23 | |
| 24 | moddirs="$(find . -name go.mod | sed 's;/go.mod;;')" |
| 25 | |
| 26 | for dir in $moddirs |
| 27 | do |
| 28 | syncmod $dir |
| 29 | done |
| 30 | |
| 31 | go work sync |
| 32 | |
| 33 | for dir in $moddirs |
| 34 | do |
| 35 | tidymod $dir |
| 36 | done |