随笔分类 - golang
摘要:package main import ( "container/ring" "fmt" ) var size int = 10 func main() { myRing := ring.New(size) fmt.Println("Empty ring:", *myRing) for i := 0
阅读全文
摘要:1、安装 gRPC 和 Protobuf protobuf 安装链接:https://liqiang.io/post/install-protobuf-in-centos-f0a9b926 protoc-gen-go 二进制构建 git clone https://github.com/golang
阅读全文
摘要:源码链接:https://github.com/zupzup/boltdb-example.git package main import ( "bytes" "encoding/json" "fmt" "github.com/boltdb/bolt" "log" "time" ) // Confi
阅读全文
摘要:package main import ( "fmt" "time" "github.com/florianl/go-conntrack" ) func main() { // 创建 conntrack 客户端 client, err := conntrack.Dial(nil) if err !=
阅读全文
摘要:安装 graphviz yum install graphviz 开始采集: go tool pprof http://192.168.100.100:1000/debug/pprof/heap 输出 svg 文件,web可以查看 #go tool pprof http://192.168.100.
阅读全文
摘要:报错信息: error obtaining VCS status: exit status 128 解决办法: go env -w GOFLAGS="-buildvcs=false"
阅读全文
摘要:参考链接:https://studygolang.com/articles/12972 func main() { wg := sync.WaitGroup{} wg.Add(100) for i := 0; i < 100; i++ { go func(i int) { fmt.Println(i
阅读全文
摘要:package main import ( "fmt" "runtime" ) func main() { fmt.Println(runtime.GOOS) fmt.Println(runtime.GOARCH) } 结果: #go run go-cpu.go linux amd64
阅读全文
摘要:参考链接: https://www.geek-share.com/detail/2712555235.html go语言中在用binary.Read(),把二进制映射为结构体时,如果出现panic: reflect: reflect.Value.SetUint using value obtaine
阅读全文
摘要:问题:版本不支持 #tc filter add dev veth100 ingress bpf da obj proxy.o sec tc No ELF library support compiled in. 解决: # 安装libbpf: git clone https://github.com
阅读全文
摘要:demo package main import "fmt" func main() { s := make([]string, 10) // 前10个元素没初始化,就是10个空字符串 fmt.Println(len(s)) s = append(s, "111111") // 第11位追加字符串
阅读全文