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

proposal: errors: change interface error #52447

Closed
renanbastos93 opened this issue Apr 20, 2022 · 5 comments
Closed

proposal: errors: change interface error #52447

renanbastos93 opened this issue Apr 20, 2022 · 5 comments

Comments

@renanbastos93
Copy link

Hello,
Another day I talked with a workmate and we perceived that's package has an interface validate only method Error() maybe we should validate likewise Is/As/Unwrap.

See lines below:


I will propose two ways then we need to choose only one.

  1. Add these methods to the interface error
type error interface {
	Unwrap() error
	Is(error) bool
	As(any) bool
	Error() string
}
  1. Create a new interface public
type Error interface {
	Unwrap() error
	Is(error) bool
	As(any) bool
	Error() string
}

Does this make sense?

see ya Gophers

@gopherbot gopherbot added this to the Proposal milestone Apr 20, 2022
@seankhliao
Copy link
Member

Duplicate of #39539

@seankhliao seankhliao marked this as a duplicate of #39539 Apr 20, 2022
@renanbastos93
Copy link
Author

@seankhliao is not exactly equal to the issue you commented on but is similar. I saw other issues similar to it so I did understand why you closed it. Thanks a lot

@DeedleFake
Copy link

DeedleFake commented Apr 20, 2022

@renanbastos93

Adding methods to an existing interface definition is not backwards compatible. There are essentially no circumstances under which new methods will be added directly to error. It would break a lot of existing code.

@renanbastos93
Copy link
Author

@DeedleFake thanks a lot for explaining to me.

@golang golang locked and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants