The snippet library.
Small, practical examples. Search by task or narrow things down below.
Read quoted CSV fields
Read quoted CSV fields 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
Read text line by line
Read text line by line using a complete Go program with explicit sample inputs.
Go✓ Tested
Receive a result from a goroutine
Receive a result from a goroutine using a complete Go program with explicit sample inputs.
Go✓ Tested
Reject an escaping relative path
Reject an escaping relative path using a complete Go program with explicit sample inputs.
Go✓ Tested
Reject an integer outside a byte’s range
Reject an integer outside a byte’s range using a complete Go program with explicit sample inputs.
Go✓ Tested
Reject non-finite numeric input
Reject non-finite numeric input using a complete Go program with explicit sample inputs.
Go✓ Tested
Reject unknown JSON object fields
Reject unknown JSON object fields using a complete Go program with explicit sample inputs.
Go✓ Tested
Remove a slice range
Remove a slice range using a complete Go program with explicit sample inputs.
Go✓ Tested
Remove an optional prefix
Remove an optional prefix 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
Replace literal text
Replace literal text using a complete Go program with explicit sample inputs.
Go✓ Tested