iterutil

package
v0.23.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Map

func Map(err error) error

Map the nil if it is StopIteration, or keep the error otherwise

func StopIteration

func StopIteration() error

StopIteration returns a sentinel error that indicates stopping the iteration.

This error should not be propagated further, i.e., if a closure returns this error, the loop should break returning nil error. For example:

f := func(i int) error {
	if i == 10 {
		return iterutil.StopIteration()
	}
	return nil
}

for i := range slice {
	if err := f(i); err != nil {
		return iterutil.Map(err)
	}
	// continue when nil error
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL