- 博客(14)
- 收藏
- 关注
转载 Golang struct、interface 组合嵌入类型详解
https://www.jianshu.com/p/d87c69ac6ce7 概述 在 Go 语言中,如果一个结构体和一个嵌入字段同时实现了相同的接口会发生什么呢?我们猜一下,可能有两个问题: 编译器会因为我们同时有两个接口实现而报错吗? 如果编译器接受这样的定义,那么当接口调用...
2018-06-11 13:24:00
684
转载 golang socket的send和recv。
一方可以给另一方发送短数据,不会阻塞,但是如果另一方不及时接收,导致缓冲区写满,就会阻塞。 转载于:https://my.oschina.net/u/3665115/blog/182790...
2018-06-11 09:12:00
593
转载 Go语言中的Array、Slice、Map和Set使用详解
http://www.jb51.net/article/56828.htm 转载于:https://my.oschina.net/u/3665115/blog/1607428
2018-01-15 17:44:00
220
转载 测试channel
select中如果有default,则不会阻塞。 在关闭的channel上接收数据,不会阻塞。并且有(1)a := <- ch。 (2)b, ok := <- ch两种接收模式。第二种可以通过ok判断channel是否已关闭。 在未关闭读channel上接收数据。两种...
2017-12-09 15:15:00
469
转载 测试smux
github.com/xtaci/smux 把conn封装为session。在session上通过创建stream交流。一个stream可以来回多次发送消息。 在client和server之间建立起一个连接conn后,通过smux.Client和smux.Server把conn封...
2017-12-09 15:05:00
622
转载 测试pfilter
github.com/AudriusButkevicius/pfilter 把一个物理读conn1传给PacketFilter做封装。可以给PacketFilter传入filter,返回conn2。通过filter来处理从物理conn1读取的数据,或者要写入到物理conn1的数据。 ...
2017-12-09 06:19:00
223
转载 指针传递测试
指针传递和c语言一样。 指针本身是值传递。可以在函数中通过指针修改所指对象的内容。 在函数内修改指针本身不会影响指针之前指向的内容。 package mainimport ( "fmt")type A struct { V int}func test(a ...
2017-09-29 14:53:00
73
转载 io.Pipe测试
管道会返会Reader和Writer。只有把所有数据读光了才会再写。 package mainimport ( "io" "fmt" "time")func test() { r,w := io.Pipe() go func(r *io.Pipe...
2017-09-09 16:39:00
136
转载 log测试
package mainimport ( "log")func test() { log.SetFlags(log.Ldate |log.Lmicroseconds | log.Lshortfile) log.Println("hello") log.SetPrefix("te...
2017-09-07 15:29:00
379
转载 string测试
package mainimport (_ "fmt")func test() { s := "打分fff"; for _, i := range s { println(i) } println("----------") for i:=0; i < len(s)...
2017-09-07 09:52:00
97
转载 golang参数传递
1 map和slice本身是值传递。但是如果修改他们指向的内容,会影响到函数外。 2 对map和slice的复制,他们底层指向和操作的还是同一对象。 package mainimport ( "fmt")func test2(m map[string]int) { ...
2017-09-03 16:21:00
130
转载 go元素初始化
原文: When storage is allocated for avariable, either through a declaration or a call ofnew, or when a new value is created, either through a com...
2017-09-03 09:03:00
138
转载 gob编码解码
gob可以正确编码解码slice和指针。 package mainimport ( "bytes" "encoding/gob" "fmt" "log")type Fobj struct { Path string Stamp in...
2017-09-03 08:44:00
226
转载 context测试。
package mainimport ( "context" "time" "sync")func dolongtime(ctx context.Context, cancel context.CancelFunc) { defer cancel() //for i:=0;...
2017-08-29 12:43:00
178
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人