mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-19 03:25:44 +00:00
8 lines
435 B
Plaintext
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"
|