Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support for obtaining a stack trace without requiring github.com/pkg/errors

未关闭
#130 0 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
go
领域
backend

调研方向

首先定位 package 当前对 github.com/pkg/errors 的使用以及堆栈跟踪的访问方式。将现有行为与提议的 StackTrace() []uintptr 接口和替代的 Callers() []uintptr 接口进行比较。当不同 package 中的错误无需依赖 github.com/pkg/errors 即可公开或保留堆栈跟踪,并且兼容性预期已得到解决时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

I made a spiritual successor of github.com/pkg/errors some time ago and in it I want to know if an error already contains a stack trace. The goal is that if a large codebase uses different packages for errors, they should work together and not hide existing recorded information, like a stack trace.

One of the issues with github.com/pkg/errors is that its stackTracer interface uses a custom type only exported by github.com/pkg/errors. And it seems this package relays heavily on that and reuses it and even re-exports it.

I would suggest that instead, the following interface is implemented:

type stackTracer interface {
        StackTrace() []uintptr
}

Then, it is easy to obtain a stack trace, use it, format it, and one does not have to depend on a library which created the error.

If you do want to keep using github.com/pkg/errors and re-exporting it and keeping its interface (to prevent a breaking change), I have seen also the following interface being used in this package:

type goErrorsStackTracer interface {
	Callers() []uintptr
}

But given that github.com/pkg/errors is deprecated, then it is probably reasonable to drop its direct use (this package seems to use it for stack formatting as well) and just change the function to StackTrace() []uintptr.

(As I mentioned in #70, you can also use my package as drop-in maintained replacement for github.com/pkg/errors which provides same stack frame formatting features, but does not lock you in into custom types just to access a stack trace.)

主要语言
Go
星标
2.5k
派生
75
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cockroachdb/errors 的其他 Issue

查看 cockroachdb/errors 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。