Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint common error wrapping issues, update README #1969

Merged
merged 2 commits into from Dec 11, 2023

Conversation

helsaawy
Copy link
Contributor

Enable errorlint to catch common issues with wrapping and testing for errors.

Wherever possible, switched to using errors.Is and errors.As. Exceptions:

  • function is defined in the same package and explicitly returns a know error variable
  • returns from functions in io, binary, context, syscall, golang.org/x/sys/windows, or golang.org/x/sys/unix that are (relatively) stable in error return value and type
  • conversion would interact with with github.com/pkg/errors
  • conversion would be non-trivial and require additional testing/validation
    • specifically, legacy code in runhcs and the root of the repo

Rename context to ctx in pkg\go-runhcs\*.go to avoid overshadowing context package.

Update README.md:

  • run markdown formatter (spaces around code blocks and headers, raw link URLS)
  • add section on linter and go generate (similar to go-winio's)

@helsaawy helsaawy requested a review from a team as a code owner November 14, 2023 16:33
Enable `errorlint` to catch common issues with wrapping and testing for errors.

Wherever possible, switched to using `errors.Is` and `errors.As`.
Exceptions:
- function is defined in the same package and explicitly returns a
  know error variable
- returns from functions in `io`, `binary`, `context`, `syscall`,
  `golang.org/x/sys/windows`, or `golang.org/x/sys/unix` that are
  (relatively) stable in error return value and type
- conversion would interact with with `github.com/pkg/errors`
- conversion would be non-trivial and require additional
  testing/validation
  - specifically, legacy code in `runhcs` and the root of the repo

Rename `context` to `ctx` in `pkg\go-runhcs\*.go` to avoid
overshadowing `context` package.

Update `README.md`:
- run markdown formatter (spaces around code blocks and headers, raw link URLS)
- add section on linter and go generate (similar to go-winio's)

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
README.md Outdated Show resolved Hide resolved
hcn/hcnerrors.go Outdated Show resolved Hide resolved
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@helsaawy helsaawy merged commit 7ec8848 into microsoft:main Dec 11, 2023
18 of 19 checks passed
@helsaawy helsaawy deleted the errorlint branch December 11, 2023 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants