The snippet library.
Small, practical examples. Search by task or narrow things down below.
Sort integers in place
Sort integers in place using a complete Go program with explicit sample inputs.
Go✓ Tested
Sort map keys for stable output
Sort map keys for stable output using a complete Go program with explicit sample inputs.
Go✓ Tested
Sort records by a selected field
Sort records by a selected field using a complete Go program with explicit sample inputs.
Go✓ Tested
Split a key-value pair once
Split a key-value pair once using a complete Go program with explicit sample inputs.
Go✓ Tested
Split on repeated whitespace
Split on repeated whitespace using a complete Go program with explicit sample inputs.
Go✓ Tested
Test an HTTP handler without a server
Test an HTTP handler without a server 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
Trim surrounding whitespace
Trim surrounding whitespace using a complete Go program with explicit sample inputs.
Go✓ Tested
Try a channel receive without blocking
Try a channel receive without blocking 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
Use a condition-only for loop
Use a condition-only for loop using a complete Go program with explicit sample inputs.
Go✓ Tested