Go Ubuntu: Old School Style
If you're the type of person who likes cute interfaces and feature-packed tools, this article might not be for you. Here, let's do things the old-fashioned way, like our ancestors did. In the end, you will leave with Go installed and running, without the need for IDEs or polished interfaces (in case the frontend world ends for good).
What you will need:
- Distributions based on Debian/Ubuntu, as the commands here are specific to this scenario;
- Visual Studio Code installed (step-by-step link);
- Sanity (optional, depending on the level of your GUI needs).
Installation
Open the terminal and paste the following command:
sudo apt install golang-go
sudo: is necessary to ensure that the command will be executed with administrator permissions (the famous "root");
apt: is the Ubuntu package management tool, used to install, update and remove software;
install: indicates that we are asking the system to install a new package;
golang-go: is the package you are installing, that is, Go (also known as Golang).
This command will install the version of Go present in the official Ubuntu repositories. The disadvantage is that this version is often not the most recent, as the repositories may not always be updated with the latest versions of all tools.
What if I want the most current version of Go?
To ensure you have the latest version of Go available, use the following commands:
sudo add-apt-repository ppa:longsleep/golang-backports sudo apt update sudo apt install golang-go
sudo add-apt-repository ppa:longsleep/golang-backports: is the command that will add a backports repository to your system. Backport repositories are like “alternative paths” to obtain newer versions of packages that are not in the official repository;
sudo apt update: will update the list of available packages and ensure that the system is aware of this new source of packages;
sudo apt install golang-go: ensures that you download the most current version of Go available in this backports repository.
Checking the installed version
After installation, check if Go was installed correctly by running the following command:
go version
This should return something like:
go version go1.23.4 linux/amd64
Now you're ready to take over the world with Go... or at least finish following the tutorial, if you don't mind.
It went wrong, what now?
Now turn around, right? The world will not dominate itself alone.
Programming in Go using VSCode
Now that Go is in the system, it's time to code using the VSCode terminal (I promise it doesn't hurt).
Open VSCode through the terminal with the command:
sudo apt install golang-go
Create a new project:
sudo add-apt-repository ppa:longsleep/golang-backports sudo apt update sudo apt install golang-go
If the following message in vbnet is as follows, then it means it worked.
go version
Now, run the ls command to list the files and create the directory structure:
go version go1.23.4 linux/amd64
mkdir: the command used to create a directory (a folder);
-p: option that allows you to create subdirectories, if they do not exist, without generating an error. For example, if you want to create a folder inside another, -p will create all the folders in the path at once;
project-name: is the name you choose for the directory that will be created, that is, we are creating the folder where we will store all the files of your Go project;
cd: means "change directory", changing directory. It is used to navigate between directories (folders) on your file system;
project-name: is the directory we just entered. So, after running this command, the terminal will be inside the project-name folder, where you can start working and adding files;
touch: command used to create an empty file. In this case, it creates the main.go file within the project-name directory (if the file already exists, the command updates the modification date and time);
main.go: Go file where we will write the code for our project;
code: command to open VSCode, if you have it installed and configured in your terminal;
main.go: file you just created, which will be opened directly in VSCode. This is useful to launch the file and start programming in Go directly from within the editor.
Now, finally inside main.go, paste the following code for a simple "Hello":
code .
Run via terminal:
go mod init nome-projeto
Ready! Now you will definitely dominate the world.
Want to be more old school? More coming!
Now, if you want to be more "thick", how about creating the file directly in the terminal without using a text editor?
Open the terminal in Ubuntu and create a file called hello.go with the Go code directly in it:
go: creating new go.mod: module projeto go: to add module requirements and sums: go mod tidy
echo -e allows you to print multiple lines of text in the terminal (and -e interprets line breaks and other special characters);
The text between the quotes is the Go code we are inserting into the file;
> hello.go redirects the output of the echo command to the file hello.go.
Now, let's definitely raise the level.
Running...
sudo apt install golang-go
This command will compile and execute the Go file at the same time, resulting in:
sudo add-apt-repository ppa:longsleep/golang-backports sudo apt update sudo apt install golang-go
Modifying the code directly in the terminal
If you want to make small changes to the code directly in the terminal, you can use echo again. For example, if you want to change the message to "Hello, World!", run the command:
go version
Then run again:
go version go1.23.4 linux/amd64
Tip: using echo with redirection is a quick and effective way to create small files directly through the terminal. However, for larger projects, you will need a text editor like nano or vim in the terminal.
Conclusion
No more, except that now you are a true legend, and you will make this world a bluer place. GO!
The above is the detailed content of Go Ubuntu: Old School Style. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

OpenSSL, as an open source library widely used in secure communications, provides encryption algorithms, keys and certificate management functions. However, there are some known security vulnerabilities in its historical version, some of which are extremely harmful. This article will focus on common vulnerabilities and response measures for OpenSSL in Debian systems. DebianOpenSSL known vulnerabilities: OpenSSL has experienced several serious vulnerabilities, such as: Heart Bleeding Vulnerability (CVE-2014-0160): This vulnerability affects OpenSSL 1.0.1 to 1.0.1f and 1.0.2 to 1.0.2 beta versions. An attacker can use this vulnerability to unauthorized read sensitive information on the server, including encryption keys, etc.

Backend learning path: The exploration journey from front-end to back-end As a back-end beginner who transforms from front-end development, you already have the foundation of nodejs,...

Queue threading problem in Go crawler Colly explores the problem of using the Colly crawler library in Go language, developers often encounter problems with threads and request queues. �...

The library used for floating-point number operation in Go language introduces how to ensure the accuracy is...

Under the BeegoORM framework, how to specify the database associated with the model? Many Beego projects require multiple databases to be operated simultaneously. When using Beego...

The difference between string printing in Go language: The difference in the effect of using Println and string() functions is in Go...

The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

What should I do if the custom structure labels in GoLand are not displayed? When using GoLand for Go language development, many developers will encounter custom structure tags...
