Go
Beginner
1 min read
What Is Go and Why Use It
Example
// hello.go — a minimal Go program
package main
import (
"fmt"
"runtime"
)
func main() {
// Print a greeting
fmt.Println("Hello, Go!")
// Show some runtime information
fmt.Printf("Go version : %s\n", runtime.Version())
fmt.Printf("OS : %s\n", runtime.GOOS)
fmt.Printf("Architecture: %s\n", runtime.GOARCH)
fmt.Printf("CPUs : %d\n", runtime.NumCPU())
// Demonstrate basic variable declaration
language := "Go"
year := 2009
fmt.Printf("%s was first released in %d.\n", language, year)
// A simple loop
for i := 1; i <= 3; i++ {
fmt.Printf("Iteration %d\n", i)
}
}