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

Copy a slice without sharing storage

Copy a slice without sharing storage using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFiles & paths

Copy a stream and count its bytes

Copy a stream and count its bytes using a complete Go program with explicit sample inputs.

Go✓ Tested
GoMaps & sets

Copy entries into another map

Copy entries into another map using a complete Go program with explicit sample inputs.

Go✓ Tested
GoMaps & sets

Count repeated words

Count repeated words using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Count Unicode code points

Count Unicode code points using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFiles & paths

Create and clean up a temporary file

Create and clean up a temporary file using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFiles & paths

Create nested directories

Create nested directories using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Declare a fixed-size array

Declare a fixed-size array using a complete Go program with explicit sample inputs.

Go✓ Tested
GoGetting Started

Declare and update a variable

Declare and update a variable using a complete Go program with explicit sample inputs.

Go✓ Tested
GoJSON & encoding

Decode JSON into a typed struct

Decode JSON into a typed struct using a complete Go program with explicit sample inputs.

Go✓ Tested
GoSlices & collections

Deduplicate sorted values

Deduplicate sorted values using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFunctions & types

Define related integer constants

Define related integer constants using a complete Go program with explicit sample inputs.

Go✓ Tested