How to Install Golang in Termux?
Termux is a command-line terminal emulator app for android built using JAVA language. It is built by Fredrik Fornwall. It has a Linux environment built within it, and it doesn’t require any rooting or separate setup to run the terminal emulator.
Go is a modern programming language built by Google Engineers. Go language is also called “Golang” and it was first released on November 10, 2009. Its syntax is somewhat similar to the C language. It is widely used for writing microservices.
To install Golang in the terminal, we have to follow the following steps :
Step 1: Download and install the termux from the play store, simply go through the following link and download the termux.
Or, go through the following link to install Termux from F-droid.
Step 2: Open up the termux app and run the following command to install Golang.
pkg install golang
It will install the latest version of Golang in termux.
Step 3: Let’s create a simple program in Golang:
open up the terminal emulator app and run the following command:
nano is a prebuilt text editor that comes with the installation of termux, running the above command will create a file named geeks with extension .go. Now paste the code written below and press Ctrl+X and confirm saving by typing Y.
It will save the Golang hello world program.
Step 4: To compile and run the above program run the following command:
This command will compile the geeks.go program and results in an executable file.
go build geeks.go
The file with green in color is the result of the above command, it is an executable file generated from geeks.go.
Step 5: To run the above program run the following command:
Simply “./” followed by file name to run the Golang program.
Please Login to comment...