Go
Go
Installation
Ubuntu
apt install golang
AlmaLinux
dnf install golang
Arch Linux
pacman -S go
Binary
# Download go{version}{os}-{arch}.tar.gz from https://go.dev/
tar xzf go{version}{os}-{arch}.tar.gz
mv go /usr/local
export PATH=/usr/local/go/bin:$PATH
Examples
Fibonacci Numbers
// Fibonacci Numbers
package main
import "fmt"
import "flag"
func fib(n int) int {
if n < 2 {
return n
} else {
return fib(n-2) + fib(n-1)
}
}
func main() {
var n = flag.Int("n", 0, "usage")
flag.Parse()
fmt.Println(fib(*n))
}
/*
example
compile:
go build fib.go
run:
./fib -n 39
*/