Golang install linux mint

How To Install Go 1.20 on LinuxMint 21/20/19

Go is an open-source programming language developed by a team at Google. It provides easy-to-build simple, reliable, and efficient software. This language is designed for writing servers, that’s why it is used widely these days. Go has released the latest version 1.20.

This tutorial will help you to install Go 1.20 on your LinuxMint 21/20/19 systems.

To install Golang on Debian system visit below link:

Step 1: Install Golang on Linux Mint

Login to your Linux Mint system using ssh and upgrade to apply the latest security updates.

sudo apt-get update sudo apt-get upgrade 

Then download the Go language binary archive file using the following link. To find and download latest version available or 32 bit version go to official download page.

wget https://go.dev/dl/go1.20.linux-amd64.tar.gz 

Now extract the downloaded archive and install it to the desired location on the system. For this tutorial, I am installing it under /usr/local directory. You can also put this under the home directory (for shared hosting) or other location.

tar -xvf go1.19.linux-amd64.tar.gz mv go /usr/local 

Step 2: Setup Go Environment

Now you need to setup Go language environment variables for your project. Commonly you need to set 3 environment variables as GOROOT, GOPATH and PATH.

GOROOT is the location where Go package is installed on your system.

GOPATH is the location of your work directory. For example my project directory is ~/Projects/Proj1 .

export GOPATH=$HOME/Apps/app1 

Now set the PATH variable to access go binary system wide.

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH 

All above environment will be set for your9 current session only. To make it permanent add above commands in ~/.profile file.

Step 3: Verify Installation

At this step, you have successfully installed and configured go language on your system. First, use the following command to check the Go version.

go version  go version go1.20 linux/amd64

Now also verify all configured environment variables using following command.

go env  GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build661994963=/tmp/go-build" CXX="g++" CGO_ENABLED="1"

Источник

Читайте также:  Обновить qt creator linux

How to Install Go (Golang) on Linux Mint 21/20

LinuxCapable

Go, also known as Golang, is an open-source programming language developed by Google engineers Robert Griesemer, Rob Pike, and Ken Thompson. First released in 2009, it has since gained popularity due to its simplicity, efficiency, and modern features. Go is particularly well-suited for concurrent programming, which enables it to handle multiple tasks simultaneously. Its design makes it a strong choice for building web servers, networking tools, data pipelines, and other types of software.

Some key aspects that differentiate Go from other programming languages include the following:

  • Simplicity: Go’s syntax is simple and easy to learn, focusing on readability and maintainability. This makes it an excellent choice for developers who are new to programming or experienced developers looking to pick up a new language quickly.
  • Concurrency: Go’s built-in support for concurrency, enabled through goroutines and channels, allows for simultaneous efficient and straightforward handling of multiple tasks. This is especially useful in modern software development, where applications often need to handle many simultaneous connections and data streams.
  • Static Typing and Garbage Collection: Go is a statically typed language, meaning the variable data types are determined at compile time. This can help catch potential errors early in the development process. Additionally, Go features garbage collection, automatically managing memory allocation and deallocation, reducing the likelihood of memory leaks and improving overall performance.
  • Cross-platform Support: Go supports cross-compilation, allowing developers to compile their code for various platforms and architectures easily. This is particularly useful for creating applications running on multiple operating systems, such as Windows, macOS, and Linux.
  • Strong Standard Library: Go has a comprehensive library that provides many functionalities, such as networking, encryption, and file handling. This allows developers to build powerful applications without relying on third-party packages.
  • Performance: Go is compiled into machine code, which typically results in faster execution than interpreted languages like Python or Ruby. Additionally, Go’s support for concurrent programming allows it to utilize modern multi-core processors, improving performance efficiently.

This introduction has provided an overview of the key features and benefits of the Go programming language. In the following guide, we will demonstrate how to install Golang on Linux Mint 21 or Linux Mint 20 distribution using the Golang Launchpad PPA for the latest versions available, making updating easier in the future.

Step 1: Import Golang Backports PPA

To ensure you have access to the latest version of Golang, you can install it from the Golang Backports PPA, which consistently maintains the most up-to-date version.

In your terminal, add the Golang Backports PPA by executing the following command:

sudo add-apt-repository ppa:longsleep/golang-backports -y

Next, update your APT repository to reflect the new addition:

Читайте также:  Установка виртуальной машины virtualbox linux mint

Step 2: Install Golang on Linux Mint

Now it’s time to install Golang on your Linux Mint system. Run the following command to start the installation process:

Once the installation is complete, verify the installed version of Golang by executing:

By following these steps, you will have successfully installed the latest version of Golang on your Linux Mint system.

Step 3: Test Golang

Now that you have installed Go, it’s time to test it by creating a small “Hello, World” program.

Create a Directory and Go File

First, create a new directory for your test program:

Next, create a Go file using the nano text editor:

Paste the following code into the editor to create a simple “Hello, World” Go program:

package main import "fmt" func main()

Save the file (CTRL+O) and exit the editor (CTRL+X).

Create a Go Module

Now, you need to create a go.mod file to manage dependencies and execute the Go file you just created:

Save the file (CTRL+O) and exit the editor (CTRL+X).

Build and Execute the Program

Navigate to the newly created directory and build the program using the following command:

cd go-hello && sudo go build

Finally, execute the “Hello, World” program with this command:

You should see the following output:

Conclusion: Installing Golang on Linux Mint

In conclusion, installing Golang on Linux Mint is a straightforward process that allows you to harness the power and simplicity of the Go programming language. Using the Golang Launchpad PPA, you can easily install and maintain the latest version of Go, streamlining your development process and ensuring access to the most up-to-date features and improvements.

To further enhance your understanding of Go and its applications, here is a list of official resources and links:

  • Go Official Website: The official website of the Go programming language provides a wealth of information, including news, updates, and details about upcoming events. Visit golang.org to stay current with the latest developments.
  • Go Documentation: Comprehensive documentation is available on the official website, covering everything from language specification to package reference. Explore the Go documentation at golang.org/doc to learn more about the language’s features and best practices.
  • Go Playground: The Go Playground is an interactive web-based environment where you can experiment with Go code in your browser. It’s a great way to quickly test code snippets without having to install anything locally. Try it out at play.golang.org.
  • Go Wiki: The Go Wiki is a community-driven resource that offers a wealth of information about Go, including articles, tutorials, and useful tips. Visit the Go Wiki at github.com/golang/go/wiki to find user-contributed content and helpful advice.
  • Go GitHub Repository: The official Go GitHub repository is where you can find the source code, contribute to the project, and report issues. Browse the repository at github.com/golang/go to view the latest code, open issues, and see ongoing development.
Читайте также:  What are disk utilities in linux

Источник

How to Install Go on Linux Mint 20?

Go is an open-source and modern programming language that is used to build efficient and reliable software. Since it is a compiled language, therefore, we can easily compile it on any platform and create an executable file.

Go can be installed on Linux Mint 20 from the base repository and the Go tarball.

Installing Go on Linux Mint 20 from the Standard Repositories

Go is open-source, therefore, it is the part of Linux Mint 20 base repository and we can install it from there.

Open the terminal and update the apt package listing:

Now, install Go with the command:

Once Go is installed, check the installed version using the command below:

As of writing, the latest version of Go is 1.16. Since the base repositories do not always include the most current version of the application, therefore an older version of Go is installed on my Linux Mint.

Installing Go on Linux Mint 20 from the Official Tarball

Complete the below-given steps to install Go on Linux Mint 20 from the official tarball:

Step 1: Download Go official tarball
First, fire up the terminal and download the Go latest official tarball:

Step 2: Extract Go tarball
Then, extract the Go archive file in the /usr/local directory with the command below:

Step 3: Set the path variable
Next, we have to set the path environment variable value in the .bashrc file. Open the .bashrc file in the text editor:

Add the below-given line in the .bashrc file, so that the system can find the Go binary files:

Step 4: Verify the Go installation
Once the path variable is set, open the new terminal window and verify the Go installation with the command:

In the output, you can see that the latest version of Go is installed on my Linux Mint 20 system.

Getting Started with Go on Linux Mint 20

Let’s create a Go file and run the first Go program:

Run your .go file with the command:

Conclusion

We can install Go on Linux Mint 20 from the base repository and the Go tarball. This post focuses on Go installation on Linux Mint 20. Moreover, we have also created and executed our first Go program.

About the author

Kamran Sattar Awaisi

I am a software engineer and a research scholar. I like to write article and make tutorial on various IT topics including Python, Cloud Computing, Fog Computing and Deep Learning. I love to use Linux based operating systems.

Источник

Оцените статью
Adblock
detector