摘要: // 只声明了指针,并没有分配内存 var slice1 []int // 申请三个元素的内存 slice1 = make([]int, 3) if slice1 == nil { fmt.Println("slice1 是一个空切片") } else { fmt.Println("slice1 是 阅读全文
posted @ 2021-03-17 19:41 从程序员到CTO 阅读(134) 评论(0) 推荐(0)
摘要: (1) 固定大小数组 1 package main 2 import "fmt" 3 4 //值拷贝 5 func printArray(myArray [4] int) { 6 7 8 for index, value := range myArray { 9 fmt.Println("index 阅读全文
posted @ 2021-03-17 19:39 从程序员到CTO 阅读(581) 评论(0) 推荐(0)
摘要: package main import "fmt" func main() { //写入defer关键字 defer fmt.Println("main end1") defer fmt.Println("main end2") fmt.Println("main::hello go 1") fmt 阅读全文
posted @ 2021-03-17 19:37 从程序员到CTO 阅读(54) 评论(0) 推荐(0)
摘要: 跟C/C++一样 阅读全文
posted @ 2021-03-17 19:36 从程序员到CTO 阅读(44) 评论(0) 推荐(0)
摘要: 在lib中,如果一个函数是大写的,则是可以外部调用的。如果函数是小写的,则只能内部调用。 阅读全文
posted @ 2021-03-17 19:33 从程序员到CTO 阅读(246) 评论(1) 推荐(0)
摘要: (1) 单返回值 1 func foo1(a string, b int) int { 2 3 fmt.Println("a = ", a) 4 fmt.Println("b = ", b) 6 9 c := 100 10 return c 12 13 } (2) 匿名多返回值 func foo2( 阅读全文
posted @ 2021-03-17 13:37 从程序员到CTO 阅读(225) 评论(0) 推荐(0)
摘要: 0 const length int = 10 1 //const 来定义枚举类型 2 const ( 3 //可以在const() 添加一个关键字 iota, 每行的iota都会累加1, 第一行的iota的默认值是0 4 BEIJING = iota //iota = 0 5 SHANGHAI / 阅读全文
posted @ 2021-03-17 13:34 从程序员到CTO 阅读(95) 评论(0) 推荐(0)
摘要: 1 var b int = 100 2 3 // 可以不指定类型,编译器根据值推断类型 4 var c = 100 5 6 fmt.Println("c = ", c) 7 fmt.Printf("type of c = %T\n", c) 8 fmt.Println("c = ", c, ",b 阅读全文
posted @ 2021-03-17 13:33 从程序员到CTO 阅读(62) 评论(0) 推荐(0)
摘要: 编译和构建 go build test.go 运行 go run test.go 1 package main 2 import "fmt" 3 func main() 4 { 5 fmt.Println(“HelloWorld”); 6 } 阅读全文
posted @ 2021-03-17 13:32 从程序员到CTO 阅读(65) 评论(0) 推荐(0)
摘要: 一 索引 二 特性 三 安装 在vscode中新建go文件,vscode会自动安装提示进行go插件的安装 1 vscode以管理员权限启动 2 解决插件安装失败的问题 VScode中安装Go插件,由于墙的原因很可能会出现如下提示 Installing github.com/mdempsky/goco 阅读全文
posted @ 2021-03-17 00:45 从程序员到CTO 阅读(85) 评论(0) 推荐(0)
交流加我QQ:39667545