FIND YOUR NEXT FEW LINES

Results for “Go”

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

182 snippets foundClear filters
CSmall algorithms & bit operations

Calculate the greatest common divisor

C: Euclid’s algorithm repeatedly replaces a pair with the divisor and remainder.

C✓ Tested
GoGetting Started

Call a function with a return value

Call a function with a return value using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFunctions & types

Capture state in a closure

Capture state in a closure using a complete Go program with explicit sample inputs.

Go✓ Tested
GoTesting & reusable helpers

Check a function with table-driven cases

Check a function with table-driven cases using a complete Go program with explicit sample inputs.

Go✓ Tested
GoTesting & reusable helpers

Check whether bytes contain valid JSON

Check whether bytes contain valid JSON using a complete Go program with explicit sample inputs.

Go✓ Tested
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