├── .gitignore ├── .vscode └── launch.json ├── Go-01-HelloGolang └── HelloGolang.go ├── Go-02-变量和常量 ├── constant.go └── variable.go └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [] 7 | } -------------------------------------------------------------------------------- /Go-01-HelloGolang/HelloGolang.go: -------------------------------------------------------------------------------- 1 | package main //定义一个包,声明包名为main,表明当前是一个可执行程序(Go通过包来管理明明空间) 2 | 3 | import "fmt" //导入一个外部包fmt 4 | 5 | func main() { // main函数,是程序执行的入口函数 6 | fmt.Println("Go Hello World!") //在终端打印出Go Hello World! 7 | } 8 | -------------------------------------------------------------------------------- /Go-02-变量和常量/constant.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Go-02-变量和常量/variable.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | 5 | //1.1、显示声明变量类型 6 | //var userName string = "小袁同学" 7 | //UserName:="哈哈哈" 8 | 9 | //1.2、类型推断声明(Type Inference) 10 | //var userName = "小袁同学" 11 | 12 | //1.3、简短变量声明(只能在方法体内声明,使用,局部变量) 13 | //userName := "小袁同学" 14 | //println(userName,UserName) 15 | 16 | //2.1 集合类型赋值 17 | //var ( 18 | // userName = "小明" 19 | // userAge = 20 20 | // isOk = true 21 | //) 22 | 23 | //2.2 直接赋值 24 | //var userName, userAge, isOk = "小明", 20, true 25 | 26 | //2.3 简短多变量赋值 27 | //userName, userAge, isOk := "小明", 20, true 28 | //println(userName, userAge, isOk) 29 | 30 | //若只想获得 userName ,则函数调用语句可以用如下方式编写: 31 | _, _, userName := GetUserInfo() 32 | 33 | println(userName) 34 | } 35 | 36 | func GetUserInfo() (userAge int, isOk bool, userName string) { 37 | return 20, true, "追逐时光者" 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GoDaily 2 | 每天Go练习、学习笔记 3 | --------------------------------------------------------------------------------