Golang or Go is a new generation programming language many new tools like Modlishka, Gobuster and more comes written in Golang. Now Golang didn't comes pre-installed with our Kali Linux machine. In this detailed article we learn how to install Golang in Kali Linux in 2020.
There is two ways to install Golang in Linux system.
There is two ways to install Golang in Linux system.
- From the Repository (If Go available in repo).
- Manual Install (Works always) .
Installing Golang from repository
Previously we need to install Golang manually but now Golang is on Kali Linux's repository to install it we need to run following command:
The installation process will took some time depending on internet speed and processing power of our machine.
Installing Golang from repository |
Configure
After the installation process is done we need to configure a little bit in our .bashrc file. We open the .bashrc file by using following command:
Then we paste these following paths at the end of .bashrc file
# Golang paths in bashrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Then we save and close .bashrc file. Then we reload and update the .bashrc by using following command:
Now we are ready to go. To check if it is everything working perfectly or not we should crate a "hello world" file in go language and run it.
Then we add the following code into the file:
package main
import "fmt"
func main() {
fmt.Printf("Hello world!\n")
}
Then we save the file and run it by using following command:
If everything is alright then we got a 'Hello World!' output.
Installing Golang manually
If there is any problem to install it from the repository we can install it from manually.
First we open a browser and go to the official download page of Golang to download it:
Download Golang from official website |
Then we click in the Linux download as shown in above screenshot to start the download process. The download is almost 120 MB.
The compressed file of Golang will be downloaded to our Downloads folder. We open a terminal window, and to navigate to Downloads folder we use following command:
Then we type following command to extracts the files:
Above command will extract the Golang in our /usr/local directory.
Configuring Golang
We need to add variables for Golang by modifying the ~/.bashrc file.
First we open the file on our mousepad text editor by using following command:
Then we paste these following paths at the end of .bashrc file
# Golang paths in bashrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Then we save and close .bashrc file. Then we reload and update the .bashrc by using following command:
Then we can check the installation is correct or not as the process mentioned above (try the same helloworld.go).
In the above described ways we can install Golang manually and from the repository. This now looks so essential because some grate cyber security weapons are available in Golang.
Enjoyed our articles ? Make sure to follow us on Twitter and GitHub, we post article updates there. To join our KaliLinuxInfamily, join our Telegram Group. We are trying to build a community for Linux and Cybersecurity. For anything we always happy to help everyone on the comment section. As we know our comment section is always open to everyone. We read each and every comment and we always reply.