package main
import("fmt")funcmain(){// 打印传统的Hello, World!
fmt.Println("Hello, World!")// 声明一个变量并赋值var age int=30
fmt.Printf("I am %d years old.\n", age)// 使用:=简写声明并初始化变量
name :="Alice"
fmt.Printf("Hello, %s!\n", name)// 声明多个变量并赋值var x, y, z int=10,20,30
fmt.Printf("x = %d, y = %d, z = %d\n", x, y, z)// 声明多个相同类型的变量var a, b, c int
a, b, c =1,2,3
fmt.Printf("a = %d, b = %d, c = %d\n", a, b, c)}
评论已关闭