File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,4 @@ source ./scripts/test_lib.sh
12
12
13
13
TARGET_GO_VERSION=" ${TARGET_GO_VERSION:- " $( cat " ${ETCD_ROOT_DIR} /.go-version" ) " } "
14
14
find . -name ' go.mod' -exec go mod edit -toolchain=go" ${TARGET_GO_VERSION} " {} \;
15
+ go work edit -toolchain=go" ${TARGET_GO_VERSION} "
Original file line number Diff line number Diff line change @@ -34,6 +34,20 @@ function verify_go_versions() {
34
34
fi
35
35
}
36
36
37
+ # Workaround to get go.work's toolchain, as go work edit -json doesn't return
38
+ # the toolchain as of Go 1.24. When this is fixed, we can replace these two
39
+ # checks with verify_go_versions go.work
40
+ toolchain_version=" $( grep toolchain go.work | cut -d' ' -f2) "
41
+ if [[ " go${target_go_version} " != " ${toolchain_version} " ]]; then
42
+ log_error " go toolchain directive out of sync for go.work, got: ${toolchain_version} "
43
+ toolchain_out_of_sync=" true"
44
+ fi
45
+ go_line_version=" $( go work edit -json | jq -r .Go) "
46
+ if ! printf ' %s\n' " ${go_line_version} " " ${target_go_version} " | sort --check=silent --version-sort; then
47
+ log_error " go directive in go.work is greater than maximum allowed: go${target_go_version} "
48
+ go_line_violation=" true"
49
+ fi
50
+
37
51
while read -r mod; do
38
52
verify_go_versions " ${mod} " ;
39
53
done < <( find . -name ' go.mod' )
51
65
if [[ " ${go_line_violation} " == " true" ]] || [[ " ${toolchain_out_of_sync} " == " true" ]]; then
52
66
exit 1
53
67
fi
68
+
69
+ log_success " SUCCESS: Go toolchain directive in sync"
You can’t perform that action at this time.
0 commit comments