Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Empty
- // Default values for numerics is 0, for strings is "" and for bool is false
- var i int
- // Long init and/or outside the scope of a function
- // Type is inferred from the assignment
- var i = 0
- // Shortcut
- // Type is inferred from the assignment
- i := 0
- // Multiple assignments
- a, b, c := "string", 0, 3.5
- // Block initialization outside of a function
- var (
- a int
- b string
- c float64
- d float32
- )
- // Constants
- const Pi = 3.14
- const (
- // Pi is 3.14 and this comment is required
- Pi = 3.14
- // Tau is half of pi, also this comment is required
- Tau = Pi / 2
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement