{"id":13564421,"url":"https://github.com/polyfloyd/go-errorlint","last_synced_at":"2025-05-14T03:09:08.617Z","repository":{"id":38099898,"uuid":"219031911","full_name":"polyfloyd/go-errorlint","owner":"polyfloyd","description":"A source code linter that can be used to find code that will cause problems with Go's error wrapping scheme","archived":false,"fork":false,"pushed_at":"2025-05-01T08:29:23.000Z","size":125,"stargazers_count":287,"open_issues_count":4,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-01T09:33:16.303Z","etag":null,"topics":["golang","linter"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polyfloyd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-01T17:27:15.000Z","updated_at":"2025-05-01T08:29:25.000Z","dependencies_parsed_at":"2023-02-01T05:46:09.528Z","dependency_job_id":"6ff43f41-c883-4adc-ae39-a1dbcdc29326","html_url":"https://github.com/polyfloyd/go-errorlint","commit_stats":{"total_commits":125,"total_committers":16,"mean_commits":7.8125,"dds":0.544,"last_synced_commit":"dd36aa0c1f39e62b4aa4ea79c8a3cc232488f652"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfloyd%2Fgo-errorlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfloyd%2Fgo-errorlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfloyd%2Fgo-errorlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfloyd%2Fgo-errorlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polyfloyd","download_url":"https://codeload.github.com/polyfloyd/go-errorlint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059508,"owners_count":22007768,"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":["golang","linter"],"created_at":"2024-08-01T13:01:31.079Z","updated_at":"2025-05-14T03:09:08.535Z","avatar_url":"https://github.com/polyfloyd.png","language":"Go","readme":"go-errorlint\n============\n\ngo-errorlint is a source code linter for Go software that can be used to find\ncode that will cause problems with the error wrapping scheme introduced in Go\n1.13.\n\nError wrapping allows for extra context in errors without sacrificing type\ninformation about the error's cause.\n\nFor details on Go error wrapping, see: https://golang.org/pkg/errors/\n\n## Installation\n```\ngo install github.com/polyfloyd/go-errorlint@latest\n```\n\n## Usage\ngo-errorlint accepts a set of package names similar to golint:\n```\ngo-errorlint ./...\n```\nIf there are one or more results, the exit status is set to `1`.\n\nTo automatically fix issues where possible, use the `-fix` flag:\n```\ngo-errorlint -fix ./...\n```\n\nThe tool can automatically fix:\n\n\u003e [!CAUTION]\n\u003e These fixes are still under development and the behavior is not yet stable.\n\u003e It is possible that it will make mistakes and cause more harm than good.\n\u003e Use with caution.\n\n1. Non-wrapping format verb for fmt.Errorf (changing `%v` to `%w`)\n2. Direct error comparisons (replacing `err == ErrFoo` with `errors.Is(err, ErrFoo)`)\n3. Type assertions on errors (replacing `err.(*MyError)` with `errors.As` usage)\n\nComplex cases like switches on errors or type switches cannot be automatically fixed.\n\n\n## Examples\n\n### fmt.Errorf wrapping verb\nThis lint is disabled by default. Use the `-errorf` flag to toggle.\n```go\n// bad\nfmt.Errorf(\"oh noes: %v\", err)\n// ^ non-wrapping format verb for fmt.Errorf. Use `%w` to format errors\n\n// good\nfmt.Errorf(\"oh noes: %w\", err)\n```\n\nYou can pass `-fix` to have go-errorlint automatically fix these issues for you.\n\n**Caveats**:\n* When using the `-errorf` lint, keep in mind that any errors wrapped by\n  `fmt.Errorf` implicitly become part of your API as according to [Hyrum's\n  Law](https://github.com/dwmkerr/hacker-laws#hyrums-law-the-law-of-implicit-interfaces).\n* This linter will flag all instances of a non-wrapped in a single `fmt.Errorf` call which will\n  break on Go 1.19 and earlier. Pass `-errorf-multi=0` to retain backwards compatibility. This\n  functionality will be passively maintained until at least Go 1.19 has been dropped from official\n  support.\n\n### Comparisons of errors\nThis lint is enabled by default. Use the `-comparison` flag to toggle.\n```go\n// bad\nerr == ErrFoo\n// ^ comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error\n\n// bad\nswitch err {\ncase ErrFoo:\n}\n// ^ switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors\n\n// good\nerrors.Is(err, ErrFoo)\n```\n\nErrors returned from standard library functions that explicitly document that\nan unwrapped error is returned are allowed by the linter. Notable cases are\n`io.EOF` and `sql.ErrNoRows`.\n\nYou can pass `-fix` to have go-errorlint automatically fix these issues for you.\n\n**Caveats**:\n* Comparing the error returned from `(io.Reader).Read` to `io.EOF` without\n  `errors.Is` is considered valid as this is\n  [explicitly documented](https://golang.org/pkg/io/#Reader) behaviour.\n  However, nothing stops 3rd party implementations from still wrapping\n  `io.EOF`, causing this linter to not detect such cases.\n\n### Type assertions of errors\nThis lint is enabled by default. Use the `-asserts` flag to toggle.\n```go\n// bad\nmyErr, ok := err.(*MyError)\n// ^ type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors\n\n// bad\nswitch err.(type) {\ncase *MyError:\n}\n// ^ type switch on error will fail on wrapped errors. Use errors.As to check for specific errors\n\n// good\nvar me MyError\nok := errors.As(err, \u0026me)\n```\n\nYou can pass `-fix` to have go-errorlint automatically fix these issues for you.\n\n## Contributing\n\nDo you think you have found a bug? Then please report it via the Github issue tracker. Make sure to\nattach any problematic files that can be used to reproduce the issue. Such files are also used to\ncreate regression tests that ensure that your bug will never return.\n\nWhen submitting pull requests, please prefix your commit messages with `fix:` or `feat:` for bug\nfixes and new features respectively. This is the\n[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) scheme that is used to\nautomate some maintenance chores such as generating the changelog and inferring the next version\nnumber.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyfloyd%2Fgo-errorlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolyfloyd%2Fgo-errorlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyfloyd%2Fgo-errorlint/lists"}