In this article, we will have explained the necessary steps to install and configure Go Lang on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Go Lang is an open source programming language developed by a team of Google engineers in 2007. Go language was designed to resolve the common criticisms of other languages while maintaining their positive characteristics and most widely used for writing servers these days.
Install Go on Debian
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
Step 2. Install Go on Debian 10.
Download the Go tarball using the following command:
Verify the downloaded file using the sha256sum command:
Now extract the downloaded tarball using following command inside /usr/local directory:
Step 3. Set Go Path.
Next, edit the $PATH environment variable so that the system knows where the Go executable binaries are located. You can do this either by appending the following line to the /etc/profile file (for a system-wide installation) or to the $HOME/.profile file:
Save the file, and apply the new PATH environment variable to the current shell session by typing:
To verify that everything is working, run go version and see if the version is returned:
Check the Go environment variables we set in previous sections:
Step 4. Build Hello world Program in Go.
First, Create a new directory for go workspace by using following command:
Now create src directory inside it typing below command:
Next create hello.go file inside src/hello directory using below command:
Add following content:
Now go to the:
And build the program using typing:
The output should look like this:
Congratulation, you have learned how to install and configure Go Lang is an open source programming language on Debian 10 Buster. If you have any question, please leave a comment below.