The snippet library.
Small, practical examples. Search by task or narrow things down below.
Inspect a value’s type
Inspect a value’s type using a complete Go program with explicit sample inputs.
Go✓ Tested
Look up a map entry
Look up a map entry using a complete Go program with explicit sample inputs.
Go✓ Tested
Map a command with switch
Map a command with switch using a complete Go program with explicit sample inputs.
Go✓ Tested
Name a fixed configuration value
Name a fixed configuration value using a complete Go program with explicit sample inputs.
Go✓ Tested
Read slice indices and values
Read slice indices and values using a complete Go program with explicit sample inputs.
Go✓ Tested
Repeat a task with a counted loop
Repeat a task with a counted loop using a complete Go program with explicit sample inputs.
Go✓ Tested
Return two values from a function
Return two values from a function using a complete Go program with explicit sample inputs.
Go✓ Tested
Run cleanup when a function returns
Run cleanup when a function returns using a complete Go program with explicit sample inputs.
Go✓ Tested
Run your first Go program
Run your first Go program using a complete Go program with explicit sample inputs.
Go✓ Tested
Test whether a number is even
Test whether a number is even using a complete Go program with explicit sample inputs.
Go✓ Tested
Understand default zero values
Understand default zero values using a complete Go program with explicit sample inputs.
Go✓ Tested
Update a value through a pointer
Update a value through a pointer using a complete Go program with explicit sample inputs.
Go✓ Tested