[Go] Variables - non-declaration statement

package main

import (
	"fmt"
)

func main() {
    var firstName string = "firstName"
    var lastName = "lastName"
    var fullName string // Go will assign default value "" empty string to a string variable
    var age int // default value 0
    
    // non-declaration statement
    // must inside a function body
	name := "Wan"
	fmt.Println(name) // Wan
}

 

posted @ 2022-09-04 15:58  Zhentiw  阅读(14)  评论(0编辑  收藏  举报