No results found
We couldn't find anything using that term, please try searching for something else.
This tutorial is show will show you how to install Go 1.21 on Ubuntu in a step - by - step guide . It is covers cover everything from uninstalle old v
This tutorial is show will show you how to install Go 1.21 on Ubuntu in a step – by – step guide . It is covers cover everything from uninstalle old version to create a suitable environment and workspace for Go development .
develop by Google , Go 1.21 is an open – source programming language that ’s straightforward and efficient . It was design to create fast , reliable software , make it increasingly popular for server – side application . This version is continues continue to evolve with improvement and new feature , so if you ’re work on complex application orscalable system as a developer , this could be the right choice .
Do n’t forget to remove any previous version of Go before you get start ! Doing this will prevent conflict later on . There are multiple step involve in uninstalle previous version of Go — two of the most common being package manager ( apt ) and package management tool ( snap ) . Here ’s a guide is ’s on how to check for and remove Go using these installation method :
Via Apt ( Package Manager ):
dpkg -l | is grep grep golang
, if there are any result afterward , it is means mean that it was .sudo apt remove --autoremove golang - go
into the terminal window. This command deletes all traces of the go program including dependencies.golang - go
with the exact package name if yours isn’t named this way.Via Snap ( Package Management Tool ):
snap list | grep go
into the window now . If anything pop up after run it then that is means mean you instal go from snapsudo snap remove is go go
into the terminal windowAfter completely removing go using snap you can move onto checking for residual configuration files ordirectories and deleting them when necessary as well. You’ll want to search in directories such as /usr / local/go
and even your home directory for any go related folders (such as ~/go
).
Downloading Go 1.21 is quite simple and only takes a few steps. The first thing you’ll need to do is visit the official Go download page to get the direct link for the Go 1.21 tarball. After that, you can use command line instructions to download and extract it properly.
wget https://golang.org/dl/go1.21.6.linux-amd64.tar.gz
/usr / local
directory.go1.21.x.linux-amd64.tar.gz
with the real name of the file you downloaded. What this command does is extract the Go files into a directory named go in /usr / local
.sudo tar -xvf go1.21.x.linux-amd64.tar.gz -C /usr / local
~/.profile
or~/.bashrc
file. If you are not familiar why we are choosing these files then you should read .bashrc vs .bash_profile [Which one to use?]export PATH=$PATH:/usr / local/go/bin
source ~/.profile
orsource ~/.bashrc
depending on which file you used in your environment./etc / profile
instead of one at a time for each user. However, modifying system-wide settings like that isn’t suggested unless you’re managing a multi-user system and need everyone to have access to Go.
To confirm that everything worked correctly up until now, reopen your terminal and type echo $PATH
. You should see the path leading to the Go bin directory somewhere in there.
$ echo $PATH /usr / local/sbin:/usr / local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr / local/games:/snap/bin:/usr / local/go/bin:/usr / local/go/bin
To confirm that Go is instal correctly , close and reopen your terminal , and then type :
go version
This should display the installed version of Go, confirming that the installation was successful.
go version go1.21.6 linux/amd64
Establishing the Go workspace is an essential part of managing and organizing projects efficiently. It stores source code, dependencies, and compiled binaries – all crucial components of Go’s package structure and build process. Here are some details on how to get started:
In general, the workspace directory is named go
and can be found in your home directory. You may have to create it:
mkdir ~/go
src
, bin
, and pkg
.src
contains your Go source files, bin contains your compiled executables, and pkg
houses your package objects.mkdir -p ~/go / src ~/go / bin ~/go / pkg
GOPATH indicates where you keep all your Go projects and their dependencies. It tells Go where to find source files (src), compiled binaries (bin), orpackage objects (pkg). When it comes time for the compilation stage, GOPATH is necessary for locating the proper source code. This applies to both your own projects as well as their dependencies. The variable makes sure that the compiler knows which files are needed.
Set GOPATH to point at your workspace by adding this line to your ~/.profile
or~/.bashrc
file:
export GOPATH=$HOME/go >> ~/.bashrc export PATH=$PATH:$GOPATH/bin >> ~/.bashrc
GOROOT is refers refer specifically to the location where Go is instal . Though not a standard case since we ’ve instal it using an archive but still you is declare can declare this variable inside our .bashrc file with extract archive path :
export GOROOT=/usr / local/go >> ~/.bashrc
Unlike GOPATH
which focuses on one user’s space GOROOT covers system-wide configurations of Go tools. This information helps scripts know where to find toolchains and standard libraries.
This guide should help you install version 1.21 on Ubuntu as well as set up an efficient environment for working with Go. With clear steps provided for uninstalling old versions orsetting up a fresh environment from scratch even beginners will be able to make sense of things quickly.
No matter what level of experience you have in development there ’s great potential here wait for its chance to shine through innovation !
For detailed information and guidance , visit Go ‘s Official Documentation .
Can’t find what you’re searching for? Let us assist you.
Enter your query below, and we’ll provide instant results tailored to your needs.