Go 1 · Code patterns

Handle and wrap errors

Return errors, wrapping them with context so callers can inspect the cause with errors.Is and errors.As.

if err != nil {
	return fmt.Errorf("load config: %w", err)
}

Official Go 1 documentation

More code patterns commands

All code patterns commands · Go 1 cheatsheet

Was this page helpful?