1
0
Fork 0
pr3-sose2026-fork/go/01-basics/01-variables.go

27 lines
540 B
Go

package main
import "fmt"
func main() {
//definition of a single variable
var a = "initial"
fmt.Println(a)
//definition of multiple variables
var b, c int = 1, 2
fmt.Println(b, c)
//definition of multiple variables with implicit type
var d = true
fmt.Println(d)
//definition of a variable without an initial value, it will be assigned the zero value of its type
var e int
fmt.Println(e)
//definition of a variable with the short declaration operator, it can only be used inside functions
f := "apple"
fmt.Println(f)
}