• Stars
    star
    1,653
  • Rank 28,028 (Top 0.6 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

update-golang is a script to easily fetch and install new Golang releases with minimum system intrusion

license Travis Build Status

update-golang

update-golang is a script to easily fetch and install new Golang releases with minimum system intrusion.

Table of Contents

Created by gh-md-toc

How it works

The script is based on official installation instructions from https://go.dev/doc/install.

This is the default behavior:

1. Search for the latest binary release in https://go.dev/dl/.

2. The script uses local system OS and ARCH to download the correct binary release. It is not harmful to run the script multiple times. Downloaded releases are kept as cache under '/usr/local'. You can erase them manually.

By default, the script only detects actual releases (not beta releases, not release candidates). However one can force any specific non-final release:

$ # force specific release candidate
$ sudo RELEASE=1.11rc1 ./update-golang.sh

3. The release is installed at '/usr/local/go'.

4. The path '/usr/local/go/bin' is added to PATH using '/etc/profile.d/golang_path.sh'.

5. Only if needed, GOROOT is properly setup, also using '/etc/profile.d/golang_path.sh'.

The script DOES NOT ever modify the GOPATH variable.

You can customize the behavior by setting environment variables (see Customization below).

Usage

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

Caution

Before running the script, make sure you have an untampered copy by verifying the SHA256 checksum.

$ wget -qO hash.txt https://raw.githubusercontent.com/udhos/update-golang/master/update-golang.sh.sha256
$ sha256sum -c hash.txt
update-golang.sh: OK

Remove

You can use the 'remove' option to undo update-golang.sh work:

$ sudo ./update-golang.sh remove

Declutter

You can use the '-declutter' option to prevent caching downloaded archives:

$ sudo ./update-golang.sh -declutter

Example

Sample session:

lab@ubu1:~$ go
The program 'go' can be found in the following packages:
 * golang-go
 * gccgo-go
Try: sudo apt install <selected package>
lab@ubu1:~$
lab@ubu1:~$ git clone https://github.com/udhos/update-golang
Cloning into 'update-golang'...
remote: Counting objects: 481, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 481 (delta 4), reused 9 (delta 2), pack-reused 468
Receiving objects: 100% (481/481), 70.22 KiB | 125.00 KiB/s, done.
Resolving deltas: 100% (248/248), done.
lab@ubu1:~$
lab@ubu1:~$ cd update-golang
lab@ubu1:~/update-golang$ sudo ./update-golang.sh
update-golang.sh: version 0.15
update-golang.sh: find_latest: found last release: 1.10.2
update-golang.sh: user: uid=0(root) gid=0(root) groups=0(root)
update-golang.sh: RELEASE_LIST=https://golang.org/doc/devel/release.html
update-golang.sh: SOURCE=https://storage.googleapis.com/golang
update-golang.sh: DESTINATION=/usr/local
update-golang.sh: RELEASE=1.10.2
update-golang.sh: OS=linux
update-golang.sh: ARCH_PROBE=uname -m
update-golang.sh: ARCH=amd64
update-golang.sh: PROFILED=/etc/profile.d/golang_path.sh
update-golang.sh: CACHE=/usr/local
update-golang.sh: GOPATH=
update-golang.sh: DEBUG=
update-golang.sh: will install golang go1.10.2.linux-amd64 as: /usr/local/go
update-golang.sh: https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz is remote
update-golang.sh: no need to download - file cached: /usr/local/go1.10.2.linux-amd64.tar.gz
update-golang.sh: remove_old_link: not found symlink for old install
update-golang.sh: untar: tar -x -f /usr/local/go1.10.2.linux-amd64.tar.gz
update-golang.sh: path: removing old settings from: /etc/profile.d/golang_path.sh
update-golang.sh: path: issuing new /usr/local/go/bin to /etc/profile.d/golang_path.sh
update-golang.sh: path: issuing /home/lab/go/bin to /etc/profile.d/golang_path.sh
update-golang.sh: golang go1.10.2.linux-amd64 installed at: /usr/local/go
update-golang.sh: testing: /usr/local/go/bin/go version
update-golang.sh: go version go1.10.2 linux/amd64
update-golang.sh: /usr/local/go/bin/go version: SUCCESS
update-golang.sh: testing: /usr/local/go/bin/go run /tmp/hello-tmpv1bX1rQN.go
update-golang.sh: hello, world
update-golang.sh: /usr/local/go/bin/go run /tmp/hello-tmpv1bX1rQN.go: SUCCESS
update-golang.sh: cleanup: /tmp/tmp.tcNY25eXNl
lab@ubu1:~/update-golang$

Customization

These environment variables are available for customization:

RELEASE_LIST=https://golang.org/doc/devel/release.html ;# search for new releases from this url
SOURCE=https://storage.googleapis.com/golang           ;# download source location
DESTINATION=/usr/local                                 ;# install destination
RELEASE=1.8.3                                          ;# force golang release
OS=linux                                               ;# force os
ARCH_PROBE='uname -m'                                  ;# force arch detection command
ARCH=amd64                                             ;# force arch
PROFILED=/etc/profile.d/golang_path.sh                 ;# update PATH, optionally set GOROOT
CACHE=/usr/local                                       ;# cache downloads in this dir
GOPATH=                                                ;# use this GOPATH
DEBUG=                                                 ;# set to enable debug

Example:

$ sudo RELEASE=1.9beta1 ./update-golang.sh

Per-user Install

Default behavior is to install Golang globally for all system users.

However you can use the environment variables to point locations to your per-user home directory.

The per-user installation does not need root (sudo) privileges.

Example installing:

This example will install Golang under ~/golang for current user only.

$ mkdir ~/golang
$ DESTINATION=~/golang PROFILED=~/.bash_profile ./update-golang.sh

Example uninstalling:

To uninstall, make sure to provide the same env vars used for installing:

$ DESTINATION=~/golang PROFILED=~/.bash_profile ./update-golang.sh remove

END

More Repositories

1

goben

goben is a golang tool to measure TCP/UDP transport layer throughput between hosts.
Go
515
star
2

jazigo

Jazigo is a tool written in Go for retrieving configuration for multiple devices, similar to rancid, fetchconfig, oxidized, Sweet.
Go
194
star
3

conbox

conbox is a Go implementation of unix-like utilities as single static executable intended for small container images.
Go
36
star
4

fugo

fugo - fun with Go. gomobile OpenGL game
Go
35
star
5

basgo

basgo compiles BASIC-lang to Golang. Then 'go build' can translate code to native executable binary.
Go
32
star
6

gwob

gwob - Pure Go Golang parser for Wavefront .OBJ 3D geometry file format
Go
32
star
7

equalfile

Go package to compare files
Go
25
star
8

gowebhello

gowebhello is a simple golang replacement for 'python -m SimpleHTTPServer'.
Go
14
star
9

disbalance

disbalance - automagic load balancer
Go
13
star
10

fetchconfig

fetchconfig is a Perl script for retrieving configuration of multiple devices
Perl
13
star
11

golang-concurrency-tricks

Golang concurrency model based on goroutines and channels is not free from sharp edges.
9
star
12

qpimd

PIM Daemon for Quagga - ATTENTION: qpimd has been merged into Official Quagga
C
7
star
13

acigo

Acigo is a Go package for interacting with Cisco ACI using API calls.
Go
6
star
14

obj

OBJ (3d geometry definition format) parser for Dart
Dart
4
star
15

a10-go-rest-client

Go golang API rest client for A10 Networks devices
Go
4
star
16

apishell

Run commands using APIs.
Go
3
star
17

awk_examples

2
star
18

hellolambda

golang aws hello world
Go
2
star
19

modhello

modhello - starter recipe for working with golang modules
Go
2
star
20

gobule

Golang Go parser for the Bule Language
Go
2
star
21

mustago

mustago - simple golang mustache template evaluation in html
JavaScript
2
star
22

kubegroup

kubegroup provides autodiscovery for groupcache peer pods in kubernetes cluster
Go
2
star
23

gateboard

gateboard resolves AWS Private API Gateway ID.
Go
1
star
24

miniapi

miniapi serves a tiny API.
Go
1
star
25

lavalake

lavalake - Manage security groups uniformly across multiple cloud providers.
Go
1
star
26

fapip

fapip stands for fast ping probe, a tool for measuring packet loss against a remote host.
C
1
star
27

sipswitchd

Experimental SIP soft switch
Go
1
star
28

suco

sun colony
Go
1
star
29

ebsnap

Shell
1
star
30

nexthop

Dynamic Internet Routing Suite in Go
Go
1
star
31

sqs-to-sns

sqs-to-sns is an utility written in Go to forward messages from AWS SQS Queues to AWS SNS Topics.
Go
1
star
32

findcidr

Go
1
star
33

gitcheat

1
star
34

jmud

JMud, mud server written in Java in 1990's.
Java
1
star
35

negentropia

Negentropia is a webgl experiment on 3D browser gaming
JavaScript
1
star