-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path.make_update.sh
More file actions
executable file
·48 lines (39 loc) · 1.15 KB
/
.make_update.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
# Function to run sed in-place with OS-specific options
sed_replace() {
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS - requires empty string after -i
sed -i '' "$@"
else
# Linux/Windows Git Bash
sed -i "$@"
fi
}
workdir=.
echo "Prepare to tidy all go.mod files in the ${workdir} directory"
# check find command support or not
output=$(find "${workdir}" -name go.mod 2>&1)
if [[ $? -ne 0 ]]; then
echo "Error: please use bash or zsh to run!"
exit 1
fi
for file in `find ${workdir} -name go.mod`; do
goModPath=$(dirname $file)
echo ""
echo "processing dir: $goModPath"
if [[ $goModPath =~ "/testdata/" ]]; then
echo "ignore testdata path $goModPath"
continue 1
fi
if [[ $goModPath =~ "/examples/" ]]; then
echo "ignore examples path $goModPath"
continue 1
fi
cd $goModPath
# Replace all github.com/gogf/gf/* dependencies version to latest
sed_replace 's|\(github\.com/gogf/gf/[^ ]*\) .*|\1 latest|' go.mod
go mod tidy
# Remove toolchain line if exists
sed_replace '/^toolchain\n/d' go.mod
cd - > /dev/null
done