Go 1.27 reference · 5 entries

Go Slices, Maps, Iterators and JSON

Sort and search slices, iterate maps in order, write iterators with iter.Seq, and encode JSON.

NameDescriptionSince
slices.Sort and slices.SortFunc Sort a slice in place in ascending order, or with a comparison function for custom and multi-key ordering. 1.21
slices.Contains, Index and BinarySearch Search slices: check membership, find an index, or binary-search a sorted slice. 1.21
maps.Keys and slices.Sorted Iterate a map's keys or values; combine with slices.Sorted for a deterministic order, since map iteration is random. 1.23
iter.Seq (range over functions) Write iterators as functions that yield values, and loop over them with for range like slices and maps. 1.23
encoding/json Marshal and Unmarshal Convert Go values to JSON and back using struct tags to name fields, omit empty values and skip fields.

Was this page helpful?