Return an error callers can inspect
Mid · fluency · 20 min · runtime go
Brief
Write loadUser(ctx context.Context, id int) (*User, error) that wraps a query failure with the operation and id using fmt.Errorf and %w, so callers can inspect the cause with errors.Is while the message stays readable.
3 progressive hints are available in the editor.
Public checks
- wraps with context — expected:
uses fmt.Errorf with %w