08 2022 档案

摘要:示例demo55 package main import ( "fmt" "time" ) func main() { intChan := make(chan int, 10) //初始化 intchan 通道 长度10 intChan2 := make(chan int, 10) //初始化 i 阅读全文
posted @ 2022-08-21 23:29 5656923 阅读(68) 评论(0) 推荐(0) 编辑
摘要:示例demo52 package main import ( "fmt" ) //taskChan <-chan 只读 //resChan chan<- 只写 //exitChan chan<- 只写 func calc(taskChan chan int, resChan chan int, ex 阅读全文
posted @ 2022-08-21 22:54 5656923 阅读(21) 评论(0) 推荐(0) 编辑
摘要:示例demo51 package main import ( "fmt" "time" ) func sendData(ch chan int) { //把数据写到通道里 for i := 0; i < 20; i++ { ch <- i fmt.Println("push data:", i) } 阅读全文
posted @ 2022-08-21 18:58 5656923 阅读(257) 评论(0) 推荐(0) 编辑
摘要://示例45 package main import "fmt" func main() { var intlink Link for i := 0; i < 10; i++ { intlink.InsertTail(i) } intlink.Trans() } //节点 type LinkNode 阅读全文
posted @ 2022-08-20 13:16 5656923 阅读(19) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" "math/rand" "sort" ) //学生结构体 type Student struct { Name string Id string Age int } type StudentArray []Student // 实现sort 接 阅读全文
posted @ 2022-08-18 22:47 5656923 阅读(83) 评论(0) 推荐(0) 编辑
摘要:golang中的接口, 1.不需要显示的实现,只要一个变量,含有接口类型中的所有方法,那么这个变量就实现了这个接口,因此,golang中没有implemet类似的关键字 2.如果一个变量含有多个interface类型的方法,那么这个变量就实现了多个接口 3.如果一个变量只含有了1个interface 阅读全文
posted @ 2022-08-18 21:53 5656923 阅读(34) 评论(0) 推荐(0) 编辑
摘要:go 协程 读写锁 和互斥锁 使用场景 读多写少 使用读写锁 读少写多 使用互斥锁 读写锁的性能是互斥锁的100倍 package main import ( "fmt" "math/rand" "sync" "sync/atomic" "time" ) func main() { testMap( 阅读全文
posted @ 2022-08-17 22:14 5656923 阅读(87) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示