-m git fetch
-vers=($(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head))
-
-ver=${vers[0]}
-dl() {
- arch=$(dpkg --print-architecture)
- f=${ver}.linux-${arch}.tar.gz
-
- if [[ -e $f ]]; then
- timestamp=$(stat -c %Y $f)
- else
- timestamp=0
- fi
- m wget -N https://dl.google.com/go/$f || ret=$?
-}
-dl
-# 8 is return code for 404. for a new release, they might not have a binary out yet
-if [[ $ret == 8 ]]; then
- ver=${vers[1]}
+# don't check for updates on go more than once a day
+yesterday=$(( $(date +%s) - 60*60*24 ))
+if (( $(stat -c %Y FETCH_HEAD) < yesterday )); then
+ m git fetch
+ touch ~/.local/gofetch
+
+ vers=($(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head))
+
+ ver=${vers[0]}
+ dl() {
+ arch=$(dpkg --print-architecture)
+ f=${ver}.linux-${arch}.tar.gz
+
+ if [[ -e $f ]]; then
+ timestamp=$(stat -c %Y $f)
+ else
+ timestamp=0
+ fi
+ m wget -nv -N https://dl.google.com/go/$f || ret=$?
+ }