...
All variables have a zero value and are pre-initialized to their zero value. For example, an int would have a zero value of 0 and a string would have a zero value of empty string "".
Initializing the variable at declaration time:
var x int = 5
Example:
Code Block |
---|
package main
import (
"fmt"
)
func main(){
var x int
x = 5
fmt.Println(x)
} |
References
...