Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Install Golang in Termux?

Improve Article
Save Article
  • Last Updated : 22 Sep, 2021
Improve Article
Save Article

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.


Installing Termux

Step 2: Open up the termux app and run the following command to install Golang.

pkg install golang


Installing Golang on termux

Installing Golang on Termux

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 geeks.go

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.



package main
import "fmt"
// Main function
func main() {
    fmt.Println("Welcome to GeeksforGeeks !!")

It will save the Golang hello world program.


Golang program

Golang 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 


geeks executable file

geeks executable file

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.



Successfully compile and run the Golang program in termux

Successfully compile and run the Golang program in Termux

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!