proposal: Go 2: make no result values expected when self has no return value too #36626
Labels
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?Ubuntu 16.04
go env
OutputWhat did you do?
fake code is here:
func B() {
}
func A() {
return B()
}
What did you expect to see?
I want this works ok
What did you see instead?
It failed
In fact, A and B all have no return values, sometimes, for example in http handler, I need to cancel function with a 400 or something else:
func handler(ctx ...) {
...
// something went wrong
ctx.StatusCode(400)
return
}
But I can not just use
return ctx.StatusCode(400)
end this function, this make my code not clean, so, may golang make return with no value legal when function itself has no return value too?thanks!!!
The text was updated successfully, but these errors were encountered: