Skip to content

Lint common error wrapping issues, update README#1969

Merged
helsaawy merged 2 commits intomicrosoft:mainfrom
helsaawy:errorlint
Dec 11, 2023
Merged

Lint common error wrapping issues, update README#1969
helsaawy merged 2 commits intomicrosoft:mainfrom
helsaawy:errorlint

Conversation

@helsaawy
Copy link
Copy Markdown
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 <[email protected]>
Comment thread README.md Outdated
Comment thread hcn/hcnerrors.go Outdated
Comment thread internal/guest/gcserr/errors.go
Signed-off-by: Hamza El-Saawy <[email protected]>
@helsaawy helsaawy merged commit 7ec8848 into microsoft:main Dec 11, 2023
@helsaawy helsaawy deleted the errorlint branch December 11, 2023 18:57
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 28, 2024
* Lint common error wrapping issues, update README

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 <[email protected]>

* PR: hcserrors(+tests), README

Signed-off-by: Hamza El-Saawy <[email protected]>

---------

Signed-off-by: Hamza El-Saawy <[email protected]>
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
* Lint common error wrapping issues, update README

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 <[email protected]>

* PR: hcserrors(+tests), README

Signed-off-by: Hamza El-Saawy <[email protected]>

---------

Signed-off-by: Hamza El-Saawy <[email protected]>
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.

3 participants