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 -yInstall Go:
pkg install golang -yCheck Go version:
go versionCreate a Go file:
nano hello.goAdd this code:
package main
import "fmt"
func main() {
fmt.Println("Hello Termux!")
}Run the program:
go run hello.goBuild a binary (executable):
go build hello.goRun the compiled file:
./helloBasic Commands
Run any Go file:
go run filename.goBuild a Go program:
go build filename.goInstall a Go package:
go install package-urlDownload module dependencies:
go mod tidyInitialize a Go module:
go mod init module-nameShow Go environment info:
go envUninstall Go:
pkg uninstall golang