2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00
cheat.sheets/sheets/_go/Declarations

8 lines
435 B
Plaintext
Raw Normal View History

2017-05-28 21:17:32 +00:00
// 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"