FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
GoGetting Started

Choose a branch with if and else

Choose a branch with if and else using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Choose floating-point division

Choose floating-point division using a complete Go program with explicit sample inputs.

Go✓ Tested
GoTesting & reusable helpers

Clamp a value to an allowed interval

Clamp a value to an allowed interval using a complete Go program with explicit sample inputs.

Go✓ Tested
GoMaps & sets

Clear all map entries

Clear all map entries using a complete Go program with explicit sample inputs.

Go✓ Tested
GoMaps & sets

Clone a map before editing it

Clone a map before editing it using a complete Go program with explicit sample inputs.

Go✓ Tested
GoErrors & validation

Combine independent validation errors

Combine independent validation errors using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Combine two Boolean conditions

Combine two Boolean conditions using a complete Go program with explicit sample inputs.

Go✓ Tested
GoTesting & reusable helpers

Compare floats within a tolerance

Compare floats within a tolerance using a complete Go program with explicit sample inputs.

Go✓ Tested
GoMaps & sets

Compare map contents

Compare map contents using a complete Go program with explicit sample inputs.

Go✓ Tested
GoStrings & text

Compare text ignoring case

Compare text ignoring case using a complete Go program with explicit sample inputs.

Go✓ Tested
GoTesting & reusable helpers

Compare two byte buffers

Compare two byte buffers using a complete Go program with explicit sample inputs.

Go✓ Tested
GoDates & times

Convert Unix seconds to UTC

Convert Unix seconds to UTC using a complete Go program with explicit sample inputs.

Go✓ Tested