~whereswaldon/gover

88a9d4fae6a74b3f3a1855ee30ab8b9592273137 — Chris Waldon 11 months ago 7992271 main
gover: handle release structural name change

Go releases now add trailing zero version components that used to be omitted.
Users will now need to specify 1.17 for 1.17.0, but 1.21.0 for 1.21. This could
be fixed by smarter logic to infer the right thing, but that will have to wait
for now.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 2 insertions(+), 3 deletions(-)

M gover
M gover => gover +2 -3
@@ 66,9 66,10 @@ install_version() {
    FILENAME=go$target.$GOOS-$GOARCH.tar.gz
    DL_PATH=$LIB_DIR/../$FILENAME
    mkdir -p "$LIB_DIR"
    echo "Downloading $target"
    echo "Downloading $target ($FILENAME)"
    if ! curl -s -L -o "$DL_PATH" "https://go.dev/dl/$FILENAME"; then
            echo "Couldn't download Go $target. Are you sure it exists?"
            echo "Go versions prior to 1.21 omitted trailing zero version components, but versions >= 1.21 should be fully-specified like 1.21.0"
            rm "$DL_PATH"
            rm -rf "$LIB_DIR"
            return 1


@@ 118,8 119,6 @@ latest_version() {
            highest_patch=$patch
        fi
    done
    if [ "$highest_minor" -eq 0 ] && [ "$highest_patch" -eq 0 ]; then echo "$highest_major"; return 0; fi
    if [ "$highest_patch" -eq 0 ]; then echo "$highest_major.$highest_minor"; return 0; fi
    echo "$highest_major.$highest_minor.$highest_patch"
}