Skip to content

Commit aedaac2

Browse files
committed
Discover last release.
1 parent ca001a4 commit aedaac2

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

update-golang.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ case "$arch" in
5252
;;
5353
esac
5454

55+
show_version() {
56+
msg version $version
57+
}
58+
59+
show_version
60+
61+
find_latest() {
62+
local last=
63+
local fetch=
64+
if hash wget 2>/dev/null; then
65+
fetch="wget -qO-"
66+
else
67+
fetch="curl --silent"
68+
fi
69+
last=$($fetch https://golang.org/doc/devel/release.html | grep -E -o 'go[0-9\.]+' | grep -E -o '[0-9]\.[0-9]+(\.[0-9]+)?' | sort | uniq | tail -1)
70+
if echo "$last" | grep -q -E '[0-9]\.[0-9]+(\.[0-9]+)?'; then
71+
msg find_latest: found last release: "$last"
72+
release=$last
73+
fi
74+
}
75+
find_latest
76+
5577
[ -n "$SOURCE" ] && source=$SOURCE
5678
[ -n "$DESTINATION" ] && destination=$DESTINATION
5779
[ -n "$RELEASE" ] && release=$RELEASE
@@ -311,10 +333,6 @@ remove_old_install() {
311333
fi
312334
}
313335

314-
show_version() {
315-
msg version $version
316-
}
317-
318336
check_package() {
319337
if hash dpkg 2>/dev/null && dpkg -s golang-go 2>/dev/null | grep ^Status | grep -q installed; then
320338
msg warning: golang-go is installed, you should remove it: sudo apt remove golang-go
@@ -348,14 +366,13 @@ case "$1" in
348366
;;
349367
esac
350368

351-
show_version
352369
show_vars | log_stdin
353370
check_package
354371

355-
msg will install golang "$label" as: "$abs_goroot"
356-
357372
cd "$destination" || die could not enter destination="$destination"
358373

374+
msg will install golang "$label" as: "$abs_goroot"
375+
359376
download
360377
remove_old_link
361378
untar

update-golang.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
51e6a830828f12f089a21cdc45ab2eee5dc4d1cb73feb64aa75d9d0ad145b9ba update-golang.sh
1+
e24ce7e0d2eda19dce857f5f2a9d54dba6b9cd156c27ea8d4a5817f437675b6c update-golang.sh

0 commit comments

Comments
 (0)