-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: Go 2: Error-Handling Paradigm with !err Grammar Sugar #63621
Comments
If the Go compiler encounters the function e( ), it automatically appends the following code on the next line: if err != nil {
return nil, err
} |
I'm sorry, I don't understand the actual proposal here. What are the |
(somehow Go2 error proposals seem to be like singing talent contests) |
I am not sure I understand the semantics of the proposal from the example provided. The syntactic sugar is too cryptic. |
Are you about typing lot's of boilerplate code like this? Modern IDEs already has live templates/code snippets. Also you can create you own snippets for your errors. Is this acceptable to you? |
Hi, if you like this idea please give a heart emoji to me, Thank you very much package main
import (
"fmt"
"os"
)
func main() {
/*
func demo(){
file, err := os.Create("example.txt")
if err != nil {
return nil, err
}
defer file.Close()
}
*/
func demo_1(){
file := os.Create("example.txt").checkError( return , nil , err )
defer file.Close()
}
func demo_2(){
file := os.Create("example.txt").checkError( panic )
defer file.Close()
}
func demo_3(){
file := os.Create("example.txt").checkError( return , func(){
return 2 + 3 , nil
})
defer file.Close()
}
if dd := demo_1(); dd.hasError {
fmt.Printf( "dd hasError" )
return
}
fmt.Printf( "dd" )
} |
This example is even more confusing, I don't understand it at all. Please write down a proper proposal detailing what the syntax is and how the compiler transforms it. Thank you. |
Do you understand this? Thank you |
func demo_1(){
file := os.Create("example.txt").checkError( return , nil , err )
defer file.Close()
// when【 .checkError( ) 】 appears,auto append file , err := os.Create("example.txt")
// when【 .checkError( return , nil , err ) 】 appears,auto append if err != nil
} |
not either, looks like a dump, but not like a fleshed-out proposal, there are good examples of issues that actually are easy to follow along and that give a concise picture. linking to the confusing issue opening itself doesn’t help. |
It doesn't look like there's a concrete proposal here, and based on the emoji voting this is likely decline. Leaving open for four weeks for additional comments. |
There were no further comments. |
Hi, if you like this idea please give a heart emoji to me, Thank you very much
The text was updated successfully, but these errors were encountered: