x := 1
fmt.Println(x)
{ // Why do we have a bracket here?
fmt.Println(x)
x += 2
fmt.Println(x)
} // And closing here?
fmt.Println(x)
The variable x is just here as part of a code i coped from another source, i just need to understand the bracket after the fmt.Printf(x) because according to golang official doc, fmt.Println returns (n int, err error).
I think the original code was trying to demonstrate that a new x can be declared inside the scope, between the curly braces, without affecting the outer x. But this sample doesn’t declare a new x so there is no reason to introduce that confusing new block.