FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
GoSlices & collections

Sort integers in place

Sort integers in place using a complete Go program with explicit sample inputs.

Go✓ Tested
GoMaps & sets

Sort map keys for stable output

Sort map keys for stable output using a complete Go program with explicit sample inputs.

Go✓ Tested
GoTesting & reusable helpers

Sort records by a selected field

Sort records by a selected field using a complete Go program with explicit sample inputs.

Go✓ Tested
GoStrings & text

Split a key-value pair once

Split a key-value pair once using a complete Go program with explicit sample inputs.

Go✓ Tested
GoStrings & text

Split on repeated whitespace

Split on repeated whitespace using a complete Go program with explicit sample inputs.

Go✓ Tested
GoHTTP & URLs

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
GoGetting Started

Test whether a number is even

Test whether a number is even using a complete Go program with explicit sample inputs.

Go✓ Tested
GoStrings & text

Trim surrounding whitespace

Trim surrounding whitespace using a complete Go program with explicit sample inputs.

Go✓ Tested
GoConcurrency & cancellation

Try a channel receive without blocking

Try a channel receive without blocking using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Understand default zero values

Understand default zero values using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Update a value through a pointer

Update a value through a pointer using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Use a condition-only for loop

Use a condition-only for loop using a complete Go program with explicit sample inputs.

Go✓ Tested