First, visit the golang website to check for the latest version available:
https://golang.org/dl/
Step 1: Now, we download the latest version:
$ wget https://dl.google.com/go/go1.15.2.linux-amd64.tar.gz
--2018-04-26 13:12:17-- https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 172.217.163.142, 2404:6800:4007:80e::200e
Connecting to dl.google.com (dl.google.com)|172.217.163.142|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 119914627 (114M) [application/octet-stream]
Saving to: go1.10.1.linux-amd64.tar.gz
go1.10.1.linux-amd64.tar.gz 100%[=====================================================================================>] 114.36M 16.1MB/s in 7.2s
2018-04-26 13:12:25 (15.8 MB/s) - go1.10.1.linux-amd64.tar.gz saved [119914627/119914627]
$
Step 2: Use sha256sum to verify the tarball:
$ sha256sum go1.15.2.linux-amd64.tar.gz
72d820dec546752e5a8303b33b009079c15c2390ce76d67cf514991646c6127b go1.10.1.linux-amd64.tar.gz
$
Step 3: Compare sha256sum hash with the one on the downloads page:
https://golang.org/dl/
Step 1: Now, we download the latest version:
$ wget https://dl.google.com/go/go1.15.2.linux-amd64.tar.gz
--2018-04-26 13:12:17-- https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 172.217.163.142, 2404:6800:4007:80e::200e
Connecting to dl.google.com (dl.google.com)|172.217.163.142|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 119914627 (114M) [application/octet-stream]
Saving to: go1.10.1.linux-amd64.tar.gz
go1.10.1.linux-amd64.tar.gz 100%[=====================================================================================>] 114.36M 16.1MB/s in 7.2s
2018-04-26 13:12:25 (15.8 MB/s) - go1.10.1.linux-amd64.tar.gz saved [119914627/119914627]
$
Step 2: Use sha256sum to verify the tarball:
$ sha256sum go1.15.2.linux-amd64.tar.gz
72d820dec546752e5a8303b33b009079c15c2390ce76d67cf514991646c6127b go1.10.1.linux-amd64.tar.gz
$
Step 3: Compare sha256sum hash with the one on the downloads page:
Step 4: Use tar to extract the tarball:
$ tar xvf go1.15.2.linux-amd64.tar.gz
x - extract
v - verbose output
f - specify a filename
Step 5: Observe that a directory named go is created at the current location:
$ ls -l | grep go
drwxr-xr-x 11 ubuntu ubuntu 4096 Mar 29 10:06 go
-rw-rw-r-- 1 ubuntu ubuntu 119914627 Mar 29 20:17 go1.15.2.linux-amd64.tar.gz
$
Step 6: Change the ownership of this folder (go) to root:
$ sudo chown root:root go
$ ls -l | grep go
drwxr-xr-x 11 root root 4096 Mar 29 10:06 go
-rw-rw-r-- 1 mhc mhc 119914627 Mar 29 20:17 go1.10.1.linux-amd64.tar.gz
$
Step 7 : Move it to the location: /usr/local
$ sudo mv go /usr/local
$
Step 8: Setting Go Path:
$ sudo vi ~/.profile
At the end of this file add the following lines. This tells Go where to look for its files
export GOPATH=$HOME/work
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Step 9: Let us now, refresh our profile by running:
$ which go
$ source ~/.profile
$ which go
/usr/local/go/bin/go
$
No comments:
Post a Comment