Variables

Variable Declaration in Go

Used to declare a variable.


Syntax
//long hand assignment
var variableName dataType
dataType = value
//short hand assignment, inferring type
variable := value

Notes

Inferred variables are automatically assigned to a primitive data type.


Example
package main

func main() {
    var year int
    year = 2016
    name := "Anthony"
}

< Type Converstion   |   Constants >

© 2018 SyntaxDB. All Rights Reserved.