Golang install in Termux | Android

What is Golang ?



Go is a programming language designed by Google engineers Robert Griesemer, Rob Pike, and Ken Thompson. Go is a statically typed, compiled language in the tradition of C, with the added benefits of memory safety, garbage collection, structural typing, and CSP style concurrency. The compiler, tools, and source code are all free and open source.

Install Golang in Android :

Open termux app and type following commands to install Golang in android phone.
$ pkg install golang
it will install the latest version of golang in your phone.

How to run Golang in Termux :

Write hello world program in golang and run go script.
$ nano hello.go

Write a Go script and run go code in termux.
// My first Program
package main

import "fmt"

func main() {
  fmt.Println("Hello, World")
}

Run your go script :

Open termux app and type following commands to run go script.
$ go run hello.go
Hello, world!
$
Now you can run any golang code in your android phone.

Compile your go script :

Open termux app and type following commands to run go script.
$ go build hello.go

Run compiled golang code in termux :

$ ./hello
Hello, World!
$
Now you can run any golang code in your android phone.

Tutorial :


Comments

Post a Comment