All     Ethical Hacking     Networking     Programming     OSINT

Go in Termux – Installation & Basic Commands

Go (Golang) is a fast and modern programming language developed by Google. It is widely used for tools, APIs, servers, and automation. Termux allows you to install Go easily on your Android phone so you can compile and run Go programs just like on a Linux system. Below are the installation steps and basic commands.

Installation

Update Termux packages:

pkg update && pkg upgrade -y

Install Go:

pkg install golang -y

Check Go version:

go version

Create a Go file:

nano hello.go

Add this code:

package main

import "fmt"

func main() {
    fmt.Println("Hello Termux!")
}

Run the program:

go run hello.go

Build a binary (executable):

go build hello.go

Run the compiled file:

./hello

Basic Commands

Run any Go file:

go run filename.go

Build a Go program:

go build filename.go

Install a Go package:

go install package-url

Download module dependencies:

go mod tidy

Initialize a Go module:

go mod init module-name

Show Go environment info:

go env

Uninstall Go:

pkg uninstall golang