This commit is contained in:
2025-11-06 22:16:56 +08:00
parent 06db3eae1f
commit d240a389ca
2 changed files with 16 additions and 10 deletions

View File

@@ -1,9 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4"> <module version="4">
<component name="Go" enabled="true" /> <component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module> </module>

19
main.go
View File

@@ -3,8 +3,19 @@ package main
import "fmt" import "fmt"
func main() { func main() {
var a = 100 // 指定变量类型并且赋值
var b int var num1 int = 18
b = 100 fmt.Println(num1)
fmt.Print("a=", a, "b=", b)
// 指定变量类型,但不赋值,使用默认值
var num2 int
fmt.Println(num2)
// 自动类型推断
var num3 = "tom"
fmt.Println(num3)
// 省略var =写为:=
num4 := "男"
fmt.Println(num4)
} }