Go — Command Reference
Go's most used commands — fast, simple, and powerful. Each example is a complete program (starts with package main). Each includes an explanation and a working example.
8 categories · 23 commands
🖥️
Output
Printing to the screen and formatting.
fmt.Println()fmt.Printf()fmt.Sprintf()📦
Variables
Variable definitions and constants.
:= (short declaration)varconst🔢
Numbers & Math
Arithmetic and the math package.
Arithmetic ( + - * / % )math.Sqrt / Pow / Max✍️
String
Methods from the len and strings packages.
len()strings.ToUpper / ToLowerstrings.Contains / ReplaceAllstrings.Split / Join📋
Array & Slice
Working with flexible lists (slices).
slice [ ]append()🗂️
Map
Key-value mappings.
map[K]VCheck if key exists (comma-ok)🔁
Condition & Loop
Decision making and the only loop: for.
if / elseswitchfor (three forms)for ... range🧩
Function
Function definition, multiple returns, and variadic functions.
funcMultiple returnVariadic (...)