package
0.0.0-20240927162453-5db3958d3114
Repository: https://github.com/tej-singh-rana/golang.git
Documentation: pkg.go.dev

# README

Install Go in Linux system

  • Download the archive file and extract it into /usr/bin/ directory.
    • In case, if we are in different directory instead of home directory. Change with cd command.
      $ cd /root/
      
    • Download archive with wget command.
      $ wget https://golang.org/dl/go1.15.8.linux-amd64.tar.gz
      --2021-02-13 10:37:13--  https://golang.org/dl/go1.15.8.linux-amd64.tar.gz
      
    • Extract it from tar command.
      $ pwd
      /root
      
      $ ls
      go1.15.8.linux-amd64.tar.gz
      
      $ tar -xvf go1.15.8.linux-amd64.tar.gz
      go/
      go/AUTHORS
      go/CONTRIBUTING.md
      go/CONTRIBUTORS
      go/LICENSE
      go/PATENTS
      go/README.md
      go/SECURITY.md
      go/VERSION
      go/api/
      ...
      
      $ ls
      go  go1.15.8.linux-amd64.tar.gz 
      
    • Copy/Move it extracted directory into /usr/bin/ directory.

      In your case might be different, so please check before copy.

      $ pwd
      /root 
      
      $ cp -r go /usr/bin/
      

      Note: To know the already existing Go path, use which command. Before installing a new version of Go, remove old one. Even you can manage multiple versions of Go in a same machine.
      Instructions to manage multiple versions of Go

      $ which go
      /usr/bin/go/bin/go
      
    • Set the PATH in user's $HOME/.bashrc file.
      $ echo 'export PATH="$PATH:/usr/bin/go/bin"' >> ~/.bashrc
      
      $ . ~/.bashrc
      

      Error:- go: cannot find GOROOT directory. To fix this issue, set the GOROOT path.

    • In my case,
      $ echo 'export GOROOT="/usr/bin/go"' >> ~/.bashrc
      
      $ . ~/.bashrc
      
    • Check the go version.
      $ go version
      go version go1.15.8 linux/amd64
      

Note :- GOPATH - Your Go source code directory {src, pkg, bin} and default for linux ($HOME/go), GOROOT - Your Go installation path.

Install Go in Windows system