Use go.work in the same way as go.sum (#100)

Go workspaces were introduced in Go 1.18:
https://go.dev/blog/get-familiar-with-workspaces

They list a go version, so we can use them in the same way as go.mod
This commit is contained in:
whi-tw 2023-05-09 15:56:42 +01:00 committed by GitHub
parent f1ab0168ea
commit b0a0ee7d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 12 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
echo ".go-version go.mod"
echo ".go-version go.mod go.work"

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
plugin_dir() {
local current_script_path=${BASH_SOURCE[0]}
cd "$(dirname "$(dirname "$current_script_path")")" || exit
pwd
local current_script_path=${BASH_SOURCE[0]}
cd "$(dirname "$(dirname "$current_script_path")")" || exit
pwd
}
install_dir() {
@ -28,14 +28,15 @@ get_legacy_version() {
current_file="$1"
basename=$(basename -- "$current_file")
if [ "$basename" == "go.mod" ]; then
GOLANG_VERSION=$(grep 'go\s*[0-9]' "$current_file" |
sed -E \
-e 's/.*heroku goVersion //' \
-e 's/[[:space:]]//' \
-e 's/go([0-9]+).*/\1/' |
head -1
)
if [[ "$basename" =~ ^go.(mod|work)$ ]]; then
GOLANG_VERSION=$(
grep 'go\s*[0-9]' "$current_file" |
sed -E \
-e 's/.*heroku goVersion //' \
-e 's/[[:space:]]//' \
-e 's/go([0-9]+).*/\1/' |
head -1
)
elif [ -e "$current_file" ]; then
GOLANG_VERSION=$(cat "$current_file")
else