How to install Golang in ubuntu with curl?

To install Go (Golang) on Linux using curl, you can follow these steps:

  1. Open a terminal on your Linux system.

  2. Download the latest version of Go using curl. First, I'll provide the command, and then I'll explain how to modify it:

curl -O https://dl.google.com/go/go1.21.3.linux-amd64.tar.gz

You'll need to replace "1.21.3" with the latest version of Go. To find the latest version, you can check the official Go downloads page.

  1. Extract the downloaded archive to /usr/local:
sudo tar -C /usr/local -xzf go1.21.3.linux-amd64.tar.gz
  1. Set up the Go environment by adding the following lines to your ~/.profile or ~/.bashrc file:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
  1. Apply the changes to your current session:
source ~/.profile

(or source ~/.bashrc if you added the lines to .bashrc)

  1. Verify the installation:
go version

This should display the installed Go version.