How to set up the Go language environment in Ubuntu?
Setting up a Go language environment in Ubuntu can be achieved by following these steps:
- You can download the Go language installation package from the official website https://golang.org/dl/. Choose the latest version that is suitable for your system architecture, typically selecting the installation package corresponding to Linux.
- Open the terminal and use the following command to unpack the installation package into the specified directory:
tar -C /usr/local -xzf go<version>.linux-amd64.tar.gz
- Set up environment variables by editing the ~/.profile or ~/.bashrc file and adding the following content:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
- To apply the environment variable configurations, execute:
source ~/.profile
- To verify if the installation is successful, run the following command to check the Go version.
go version
At this point, the Go language environment has been set up and you can start writing and running Go programs in the terminal.