随笔分类 -  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 阅读全文
posted @ 2023-08-05 16:30 salami_china 阅读(33) 评论(0) 推荐(0)
摘要:1、安装 gRPC 和 Protobuf protobuf 安装链接:https://liqiang.io/post/install-protobuf-in-centos-f0a9b926 protoc-gen-go 二进制构建 git clone https://github.com/golang 阅读全文
posted @ 2023-05-24 17:03 salami_china 阅读(59) 评论(0) 推荐(0)
摘要:源码链接:https://github.com/zupzup/boltdb-example.git package main import ( "bytes" "encoding/json" "fmt" "github.com/boltdb/bolt" "log" "time" ) // Confi 阅读全文
posted @ 2023-05-23 20:36 salami_china 阅读(28) 评论(0) 推荐(0)
摘要:package main import ( "fmt" "time" "github.com/florianl/go-conntrack" ) func main() { // 创建 conntrack 客户端 client, err := conntrack.Dial(nil) if err != 阅读全文
posted @ 2023-04-21 21:02 salami_china 阅读(195) 评论(0) 推荐(0)
摘要:安装 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. 阅读全文
posted @ 2023-03-07 14:50 salami_china 阅读(42) 评论(0) 推荐(0)
摘要:报错信息: error obtaining VCS status: exit status 128 解决办法: go env -w GOFLAGS="-buildvcs=false" 阅读全文
posted @ 2023-02-21 15:59 salami_china 阅读(2354) 评论(0) 推荐(0)
摘要:参考链接: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 阅读全文
posted @ 2022-11-29 09:32 salami_china 阅读(50) 评论(0) 推荐(0)
摘要:package main import ( "fmt" "runtime" ) func main() { fmt.Println(runtime.GOOS) fmt.Println(runtime.GOARCH) } 结果: #go run go-cpu.go linux amd64 阅读全文
posted @ 2022-10-31 10:56 salami_china 阅读(866) 评论(0) 推荐(0)
摘要:参考链接: https://www.geek-share.com/detail/2712555235.html go语言中在用binary.Read(),把二进制映射为结构体时,如果出现panic: reflect: reflect.Value.SetUint using value obtaine 阅读全文
posted @ 2022-03-01 16:16 salami_china 阅读(199) 评论(0) 推荐(0)
摘要:问题:版本不支持 #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 阅读全文
posted @ 2022-02-19 22:54 salami_china 阅读(970) 评论(0) 推荐(0)
摘要:demo package main import "fmt" func main() { s := make([]string, 10) // 前10个元素没初始化,就是10个空字符串 fmt.Println(len(s)) s = append(s, "111111") // 第11位追加字符串 阅读全文
posted @ 2021-12-07 11:00 salami_china 阅读(132) 评论(0) 推荐(0)
摘要:仓库: https://github.com/heptiolabs/healthcheck.git https://pkg.go.dev/github.com/heptiolabs/healthcheck#section-readme healthcheck 实现了一个开箱即用的Kubernetes 阅读全文
posted @ 2021-10-19 10:42 salami_china 阅读(472) 评论(0) 推荐(0)
摘要:参考链接:https://www.cnblogs.com/landv/p/13139127.html Notify函数让signal包将输入信号转发到c。如果没有列出要传递的信号,会将所有输入信号传递到c;否则只传递列出的输入信号。 signal包不会为了向c发送信息而阻塞(就是说如果发送时c阻塞了 阅读全文
posted @ 2021-09-29 11:49 salami_china 阅读(257) 评论(0) 推荐(0)
摘要:详细链接:https://www.cnblogs.com/jkko123/p/7256927.html package main; import ( "github.com/fsnotify/fsnotify" "log" "fmt" ) func main() { //创建一个监控对象 watch 阅读全文
posted @ 2021-09-29 11:44 salami_china 阅读(314) 评论(0) 推荐(0)
摘要:详细信息参考:https://www.jb51.net/article/202380.htm package main import ( "github.com/urfave/cli" "os" "log" "fmt" ) func main() { //实例化一个命令行程序 oApp := cli 阅读全文
posted @ 2021-09-29 11:32 salami_china 阅读(1067) 评论(0) 推荐(0)
摘要:参考链接:https://www.cnblogs.com/charlieroro/p/11112526.html 1.实现了对golang map的key的处理,如计算交集,并集等。 package main import ( "fmt" "k8s.io/apimachinery/pkg/util/ 阅读全文
posted @ 2021-09-28 19:58 salami_china 阅读(337) 评论(0) 推荐(0)
摘要:原文链接:https://studygolang.com/articles/13441?fr=sidebar package main import ( "fmt" "k8s.io/apimachinery/pkg/util/wait" "time" ) type stop struct { } f 阅读全文
posted @ 2021-09-27 16:37 salami_china 阅读(520) 评论(0) 推荐(0)
摘要:参考链接:https://studygolang.com/articles/26215?fr=sidebar viper 是一个配置解决方案,拥有丰富的特性: 支持 JSON/TOML/YAML/HCL/envfile/Java properties 等多种格式的配置文件; 可以设置监听配置文件的修 阅读全文
posted @ 2021-09-26 15:18 salami_china 阅读(156) 评论(0) 推荐(0)
摘要:参考链接:https://www.cnblogs.com/apocelipes/p/13907858.html 对于一个完整的嵌入资源,代码中的声明是这样的: //go:embed images var imgs embed.FS //go:embed a.txt var txt []byte // 阅读全文
posted @ 2021-09-26 15:09 salami_china 阅读(981) 评论(0) 推荐(0)
摘要:原文链接:https://studygolang.com/articles/27181 //注意 //线程池执行有两种,一种执行普通逻辑方法pool,可接受所有方法,另一种执行形同类型的方法(就是每次接收的内容方法都一样) //使用前需要先建立一个对应的pool对象,参数是容量大小和过期时间等, 如 阅读全文
posted @ 2021-09-26 13:54 salami_china 阅读(2295) 评论(1) 推荐(0)