2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-07 09:20:22 +00:00
cheat.sheets/sheets/go/Declarations
2017-05-08 20:27:00 +00:00

8 lines
435 B
Plaintext

// Type goes after identifier!
var foo int // declaration without initialization
var foo int = 42 // declaration with initialization
var foo, bar int = 42, 1302 // declare and init multiple vars at once
var foo = 42 // type omitted, will be inferred
foo := 42 // shorthand, only in func bodies, omit var keyword, type is always implicit
const constant = "This is a constant"