I'm not sure there really is a "reason", per se. The language could just as well have been designed not to require parentheses around the return types (at least I see no parsing ambiguity with that, though there might be) or designed to require parentheses in the return statement. It probably just felt more intuitive and readable to the designers at the time.
FWIW I find it more interesting that `func() T` requires no parentheses, but `func() (S, T)` does. On Tue, Jan 31, 2023 at 5:55 PM Raphael Clancy <raphael.cla...@gmail.com> wrote: > Hey all, I figured it was time to move to a "modern" language and I > thought I'd give go a try. So far, I'm really enjoying it. I'm just getting > started and I had a question about parentheses. Though, I guess it's really > about how go parses lines of code and what counts as a delimiter. > > Anyway, in the get started section on error handling > <https://go.dev/doc/tutorial/handle-errors>, why are parentheses required > around string and error here: > > func Hello(name string) (string, error) {... > > but not around message and nil here: > > return message, nil > > I tried searching a bit but I couldn't come up with anything about such a > basic topic. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/b49dc8c2-26ea-46bc-b76a-708a2537207cn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/b49dc8c2-26ea-46bc-b76a-708a2537207cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfFMoiF%3DKGZtvgHxR%3Dr-m-VcAafx2VtT5rgJDVjR-u-AkA%40mail.gmail.com.