Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
swdunlop
on Nov 20, 2012
|
parent
|
context
|
favorite
| on:
Go is PHP for the Backend
Actually, the following is valid syntax in Go 1.0 and later:
var i = 0
The use of "var" without a type is a common idiom when binding global variables, such as:
var ErrTooLarge = errors.New("bytes.Buffer: too large")
Oddly, the := shortcut is not legal in the global context. Also fun:
var ( i = 0 j = 0 )
So, going back to the original comment -- yes, Go has some odd little shortcuts and inconsistencies.
stavros
on Nov 20, 2012
[–]
Why
is := not valid in the global context? I have been bitten by this time and time again. Is there a reason for it? It makes no sense to me.
burntsushi
on Nov 20, 2012
|
parent
[–]
I believe the answer is related to the simplicity of the parser.
stavros
on Nov 20, 2012
|
root
|
parent
[–]
I see, thank you. Too bad this wart is exposed, though.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: