Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides idiomatic Go error handling, wrapping, inspection, and structured logging across codebases.
73% 100%+27 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 16 of 22 without it.
3 of 3 safety checks passed
123 agent runs
2 forksA fork is a copy of this skill that someone made so they could edit it for their own use. The original doesn't change.
%wWrapping preserves the original error in a chain that callers can inspect with errors.Is and errors.As. Errors SHOULD be wrapped at each layer to build a readable chain.
// ✓ Good — wraps with context, preserves the chain
func (s *UserService) GetUser(id string) (*User, error) {
user, err := s.repo.FindByID(id)
if err != nil {
return nil, fmt.Errorf("getting user %s: %w", id, err)
}
return user, nil
}
%w vs %v: controlling exposureUse %w within your module to preserve the error chain. Use %v at public API / system boundaries to prevent callers from depending on internal error types.
// Internal layer — wrap to preserve chain
func (r *repo) fetch(id string) error {
return fmt.Errorf("querying database: %w", err)
}
// Public API boundary — break chain to hide internals
func (s *PublicService) GetItem(id string) error {
err := s.repo.fetch(id)
if err != nil {
return fmt.Errorf("item unavailable: %v", err) // %v — callers cannot unwrap
}
return nil
}
errors.Is and errors.Aserrors.Is — match against a sentinel valueSkills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.