import("net/http"_"net/http/pprof")funcpprofServerStart(){gofunc(){http.ListenAndServe("127.0.0.1:6060",nil)// 安全起见,使用本地地址进行监听}()} 引入pprof 包后,会在默认处理器 DefaultServeMux 上注册 /debug/pprof/profile 接口的路由;调用 ListenAndServe 启动 http 服务,第二个参数传nil使用默...
对于ctx3.Value(&cancelCtxKey),因为它是valueCtx, 结合valueCtx.Value(key)源码可以看到,它的key不可能是&cancelCtxKey,因为在包外是不能获取到cancelCtxKey地址的,它是不可导出的,会走到ctx3.Context.Value(&cancelCtxKey),就是在执行ctx2.Value(&cancelCtxKey), ctx2是cancelCtx,所以会返回ctx2的地址&c...
unsafe.Sizeof(array1)) //一个数组占有8个字节,容量为4的数组其内存是就是32字节19var array2 [4]int //定义一个20array2 =array121fmt.Printf("array1的地址是:%d\narray2的地址是:%d\n",&array1[0],&array2[0])2223var n1,n2 int24n1 = 10025n2 = n1 //定义的n1和n2都是单独...
sliTest := make([]int, 2, 3) sliTest[1] = 5 sliTest[0] = 1 sliTest = append(sliTest, 6) 7.Map Go mapA := map[int]string{1:"one",2:"two"} mapA[6] = "six" //进行判断key是否存在: ifmath, ok := mapA[6]; ok { } //循环遍历:key+value for key,value := range m...
if err != nil { log.Errorf("%s, [session.handleLoop]s.WriteBytesArray(iovec len:%d) = error:%+v", s.sessionToken(), len(iovec), perrors.WithStack(err)) s.stop() // break LOOP flag = false } case <-wheel.After(s.period): if flag { if wsFlag { err := wsConn.write...
// with write barriers, if needed: *(ptr+len) = e1 *(ptr+len+1) = e2 *(ptr+len+2) = e3 return makeslice(ptr, newlen, cap) 如果是true,例如slice = append(slice, 1, 2, 3)语句,那么返回值会覆盖原变量。展开方式逻辑如下
TCP protocol's DNS query,such as google's 8.8.8.8,Proxy's DNS anti pollution server theory is starting a local DNS proxy server,It uses TCP to conduct DNS queries through father proxy. If it encrypted communicate with father proxy,Then you can make a safe and pollution-free DNS analysis....
Make sure $GOPATH or $HOME/go/bin is in your $PATH or %path%, then use it like so:# show help urlshc -h # shorten a url urlshc -url 'https://your.long.url/here' # shorten a url with keywords and expiry date urlshc -url 'https://your.long.url/here' -keywords 'word-1,...
func makechan(t *chantype, size int) *hchan { elem := t.elem // ... mem, overflow := math.MulUintptr(elem.size, uintptr(size)) if overflow || mem > maxAlloc-hchanSize || size < 0 { panic(plainError("makechan: size out of range")) ...
slice := array[2:4:7]的cap为 7-2=5 如果第一项不写,[:i:j],即认为是0 更多细节参考设计文件[14] go test 命令支持代码覆盖率报告,并提供新的go tool cover命令输出代码测试覆盖率的统计信息. The cover story[15] One major new feature of go test is that it can now compute and, with hel...