-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed as not planned
Closed as not planned
Copy link
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.error-handlingLanguage & library change proposals that are about error handling.Language & library change proposals that are about error handling.v2An incompatible library changeAn incompatible library change
Milestone
Description
Proposal Details
func exampleFunction() (any, error){
res, err := run()
err ? return nil, err
num, err := calc()
err ? return nil, errors.Errorf("calc is wrong. error is:%v", err)
// if the err need more than one line to handle
val, err := get()
if err != nil {
do1()
do2()
return nil, err
}
//or can use this( may be no need to add this):
err ? {
do1()
do2()
return nil, err
}
}
The ? can be ? or ?-> or ?! or some other symbol not using in golang before.
The ? can means if anything != nil ...
you can also add ?() to handle err return.
for example:
func exampleFunction() (any, error){
res, err := run()
err ?(nil, err) // means if err != nil return nil, err
num, err := calc()
err ?(nil, errors.Errorf("calc is wrong. error is:%v", err)) // means if err != nil return nil, errors.Errorf(balabala)
// if the err need more than one line to handle
val, err := get()
if err != nil {
do1()
do2()
return nil, err
}
//or can use this( may be no need to add this):
err ? {
do1()
do2()
return nil, err
}
}
kidandcat, xiaokentrl and AngeloCheckedchad-bekmezian-snap, mainjzb, septemhill, somtooo, psnilesh and 11 more
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.error-handlingLanguage & library change proposals that are about error handling.Language & library change proposals that are about error handling.v2An incompatible library changeAn incompatible library change