Go programming language bracket pair style

I only recently learned Go when I try my first world hello of this style:

func main() { ...somemagic... } 

and the 6g compiler says this is wrong.

But with this style:

 func main(){ ...somemagic... } 

This is normal.

Is the first style of a pair of parentheses illegal in Go?

+4
source share
2 answers

Yes. This is the result of an automatic semicolon in Go.

By the way, Go developers will format their code using gofmt and follow this formatting.

+8
source

Yes, the first form cannot work due to insertion rules with a comma .

+1
source

Source: https://habr.com/ru/post/1391263/