初始化
This commit is contained in:
3
01_basics/01_variables/go.mod
Normal file
3
01_basics/01_variables/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module variables
|
||||
|
||||
go 1.23.5
|
16
01_basics/01_variables/main.go
Normal file
16
01_basics/01_variables/main.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// 变量声明与初始化
|
||||
var name string = "Go语言"
|
||||
age := 28 // 类型推断
|
||||
|
||||
// 多变量声明
|
||||
var width, height = 100, 50
|
||||
|
||||
fmt.Println("变量示例:")
|
||||
fmt.Printf("name: %s, age: %d\n", name, age)
|
||||
fmt.Printf("width: %d, height: %d\n", width, height)
|
||||
}
|
Reference in New Issue
Block a user