mirror of
https://github.com/kennyp/asdf-golang.git
synced 2024-10-06 04:32:07 +08:00
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:
parent
f1ab0168ea
commit
b0a0ee7d85
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
echo ".go-version go.mod"
|
echo ".go-version go.mod go.work"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
plugin_dir() {
|
plugin_dir() {
|
||||||
local current_script_path=${BASH_SOURCE[0]}
|
local current_script_path=${BASH_SOURCE[0]}
|
||||||
cd "$(dirname "$(dirname "$current_script_path")")" || exit
|
cd "$(dirname "$(dirname "$current_script_path")")" || exit
|
||||||
pwd
|
pwd
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dir() {
|
install_dir() {
|
||||||
@ -28,14 +28,15 @@ get_legacy_version() {
|
|||||||
current_file="$1"
|
current_file="$1"
|
||||||
basename=$(basename -- "$current_file")
|
basename=$(basename -- "$current_file")
|
||||||
|
|
||||||
if [ "$basename" == "go.mod" ]; then
|
if [[ "$basename" =~ ^go.(mod|work)$ ]]; then
|
||||||
GOLANG_VERSION=$(grep 'go\s*[0-9]' "$current_file" |
|
GOLANG_VERSION=$(
|
||||||
sed -E \
|
grep 'go\s*[0-9]' "$current_file" |
|
||||||
-e 's/.*heroku goVersion //' \
|
sed -E \
|
||||||
-e 's/[[:space:]]//' \
|
-e 's/.*heroku goVersion //' \
|
||||||
-e 's/go([0-9]+).*/\1/' |
|
-e 's/[[:space:]]//' \
|
||||||
head -1
|
-e 's/go([0-9]+).*/\1/' |
|
||||||
)
|
head -1
|
||||||
|
)
|
||||||
elif [ -e "$current_file" ]; then
|
elif [ -e "$current_file" ]; then
|
||||||
GOLANG_VERSION=$(cat "$current_file")
|
GOLANG_VERSION=$(cat "$current_file")
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user