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?
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.
Yes, the first form can't work because of the semicolon injection rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With