Reputation: 89
I'm just new to learn Go, when I try my first hello world with this style:
func main()
{
...somemagic...
}
and the 6g compiler says that's wrong.
But with this style:
func main(){
...somemagic...
}
That's OK.
Is the first bracket pair style illegal in Go?
Upvotes: 4
Views: 432
Reputation: 91193
Yes, the first form can't work because of the semicolon injection rules.
Upvotes: 1
Reputation: 28086
Yes. That's a result of automatic semicolon insertion in Go.
By the way, Go developers format their code using gofmt
and follow that formatting.
Upvotes: 8