stability: wrap errors with %w instead of %v #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Most
fmt.Errorfcalls acrossoperation/wrap errors with%v, which converts them to strings and loses the underlying error type. Callers can't useerrors.Is/errors.Asto distinguish API failures (404 vs 500), context cancellations, or SDK error types.Affected files (non-exhaustive):
operation/milestone/milestone.gooperation/repo/branch.go,operation/repo/release.go,operation/repo/commit.go,operation/repo/file.go,operation/repo/repo.go,operation/repo/tag.go,operation/repo/tree.gooperation/label/label.gooperation/pull/pull.gooperation/wiki/wiki.gooperation/issue/issue.gooperation/search/search.gooperation/timetracking/timetracking.gooperation/user/user.gooperation/notification/notification.gooperation/packages/packages.gopkg/to/to.gooperation/actions/runs.goalready does this correctly — good reference.Suggested direction
Sweep
fmt.Errorf(".*%v", err)→fmt.Errorf(".*%w", err). Add agolangci-lintrule (errorlint) to keep new code consistent.