Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// main.go package main import ( "fmt" "strings" ) func main() { fmt.Println("Hello, Go!") // Variables name := "Alice" // short declaration var age int = 30 fmt.Printf("Name: %s, Age: %d ", name, age) // Slices (dynamic arrays) fruits := []string{"apple", "banana", "cherry"} fruits = append(fruits, "date") fmt.Println(fruits) // Maps scores := map[string]int{ "Alice": 95, "Bob": 87, } scores["Charlie"] = 92 // Range loop for name, score := range scores { fmt.Printf("%s: %d ", name, score) } // String operations upper := strings.ToUpper("hello") fmt.Println(upper) }
Result
Open