{"id":13472926,"url":"https://github.com/pkg/errors","last_synced_at":"2025-10-05T17:31:40.850Z","repository":{"id":37484040,"uuid":"48643510","full_name":"pkg/errors","owner":"pkg","description":"Simple error handling primitives","archived":true,"fork":false,"pushed_at":"2021-11-02T20:32:11.000Z","size":131,"stargazers_count":8207,"open_issues_count":42,"forks_count":698,"subscribers_count":113,"default_branch":"master","last_synced_at":"2025-01-15T07:17:30.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/pkg/errors","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-27T12:05:38.000Z","updated_at":"2025-01-15T06:48:16.000Z","dependencies_parsed_at":"2022-07-12T16:19:01.017Z","dependency_job_id":null,"html_url":"https://github.com/pkg/errors","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg%2Ferrors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg%2Ferrors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg%2Ferrors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg%2Ferrors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkg","download_url":"https://codeload.github.com/pkg/errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235424989,"owners_count":18988325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:00:59.273Z","updated_at":"2025-10-05T17:31:35.591Z","avatar_url":"https://github.com/pkg.png","language":"Go","readme":"# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge)\n\nPackage errors provides simple error handling primitives.\n\n`go get github.com/pkg/errors`\n\nThe traditional error handling idiom in Go is roughly akin to\n```go\nif err != nil {\n        return err\n}\n```\nwhich applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error.\n\n## Adding context to an error\n\nThe errors.Wrap function returns a new error that adds context to the original error. For example\n```go\n_, err := ioutil.ReadAll(r)\nif err != nil {\n        return errors.Wrap(err, \"read failed\")\n}\n```\n## Retrieving the cause of an error\n\nUsing `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.\n```go\ntype causer interface {\n        Cause() error\n}\n```\n`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example:\n```go\nswitch err := errors.Cause(err).(type) {\ncase *MyError:\n        // handle specifically\ndefault:\n        // unknown error\n}\n```\n\n[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors).\n\n## Roadmap\n\nWith the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows:\n\n- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible)\n- 1.0. Final release.\n\n## Contributing\n\nBecause of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. \n\nBefore sending a PR, please discuss your change by raising an issue.\n\n## License\n\nBSD-2-Clause\n","funding_links":[],"categories":["Misc","开源类库","Common","Go","Backend Go","Open source library","Miscellaneous","错误处理","Error Handling","\u003cspan id=\"其他-miscellaneous\"\u003e其他 Miscellaneous\u003c/span\u003e","杂项","雜項","Relational Databases","错误处理`go 语言错误处理库`","其他"],"sub_categories":["错误处理","Utility","Error Handling","Advanced Console UIs","SQL 查询语句构建库","Search and Analytic Databases","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","高級控制台界面","高级控制台界面","交流","检索及分析资料库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkg%2Ferrors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkg%2Ferrors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkg%2Ferrors/lists"}