In this tutorial, we will install the latest version of Go on Debian 12 and run a test application to test it out.
1. Let's update all packages
apt update
apt upgrade
2. Download the latest version of Go
Let's copy the link to the latest distribution by going to https://go.dev/dl/.
2.1 Download and unpack the archive
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
2.2 Add a variable to the profile file
echo "export PATH=/usr/local/go/bin:${PATH}" | sudo tee -a $HOME/.profile
source $HOME/.profile
2.3 Let's check the version
go version
go1.21.5 linux/amd64
3. Let's create a test application
mkdir go-hello
nano go-hello/hello.go
package main
import "fmt"
func main() { fmt.Printf("Hello, World\n") }
nano go-hello/go.mod
module example.com/mod
3.1 Let's compile our program
cd go-hello
go build
./mod
Hello, World!
Ready.
No Comments Yet