Click on a topic to expand and learn in detail.
package main
import "fmt"
func main() {
fmt.Println("Hello, Go!")
}
Go (Golang) is simple, fast, and widely used for backend and cloud applications.
var name string = "Alice"
age := 25 // short declaration
pi := 3.14
Go supports static typing, with easy variable declaration syntax.
func add(a int, b int) int {
return a + b
}
fmt.Println(add(5,3))
Functions are the primary way to organize code in Go.
// if-else
if age >= 18 {
fmt.Println("Adult")
} else {
fmt.Println("Minor")
}
// for loop
for i := 0; i < 5; i++ {
fmt.Println(i)
}
Go has simple syntax for conditionals and loops.
type Person struct {
Name string
Age int
}
func (p Person) Greet() {
fmt.Println("Hello", p.Name)
}
p := Person{"Alice", 25}
p.Greet()
Go supports structs, interfaces, and methods for OOP-like programming.