FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
GoJSON & encoding

Read quoted CSV fields

Read quoted CSV fields using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Read slice indices and values

Read slice indices and values using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFiles & paths

Read text line by line

Read text line by line using a complete Go program with explicit sample inputs.

Go✓ Tested
GoConcurrency & cancellation

Receive a result from a goroutine

Receive a result from a goroutine using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFiles & paths

Reject an escaping relative path

Reject an escaping relative path using a complete Go program with explicit sample inputs.

Go✓ Tested
GoErrors & validation

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
GoErrors & validation

Reject non-finite numeric input

Reject non-finite numeric input using a complete Go program with explicit sample inputs.

Go✓ Tested
GoJSON & encoding

Reject unknown JSON object fields

Reject unknown JSON object fields using a complete Go program with explicit sample inputs.

Go✓ Tested
GoSlices & collections

Remove a slice range

Remove a slice range using a complete Go program with explicit sample inputs.

Go✓ Tested
GoStrings & text

Remove an optional prefix

Remove an optional prefix using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

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
GoStrings & text

Replace literal text

Replace literal text using a complete Go program with explicit sample inputs.

Go✓ Tested