打赏
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 54 下一页
摘要: gorm gen使用 1.安装 git clone github.com/olongfen/gormgen cd cmd/gormgen/ go build -o gormgen main.go mv gormgen /usr/local/bin/ 2.使用 在结构体模型加对应的注解,//go:ge 阅读全文
posted @ 2021-06-01 16:40 苍山落暮 阅读(3109) 评论(0) 推荐(1) 编辑
摘要: makefile运行go常用命令 go经常会执行:测试、编译、运行、语法检查等命令 go vet 静态检查 go test 运行单元测试 go fmt 格式化 go build 编译 go run 运行 ... makefile示例一: BINARY="example" VERSION=1.0.0 阅读全文
posted @ 2021-06-01 14:15 苍山落暮 阅读(893) 评论(0) 推荐(0) 编辑
摘要: linux命令行录制 1.安装 # mac brew install asciinema # ubuntu sudo apt instal asciinema # windows请在CYGWIN中使用 2.使用 1.)开始录制 asciinema rec 2.)停止录制 ctrl+d 或 exit 阅读全文
posted @ 2021-05-31 09:03 苍山落暮 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 1.注释规范 https://www.cnblogs.com/zhichaoma/p/12509999.html 2.goland 插件之goanno 离线下载地址: https://plugins.jetbrains.com/plugin/14988-goanno https://github.c 阅读全文
posted @ 2021-05-27 15:11 苍山落暮 阅读(1686) 评论(0) 推荐(0) 编辑
摘要: golang奇偶数交叉打印 package main import ( "fmt" "sync" ) func main() { // 定义打印数据 numberList := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} // 定义两个channel用于互相通信 ch1 阅读全文
posted @ 2021-05-27 14:26 苍山落暮 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 1.生成proto文件 protoc --proto_path=.:$GOPATH/src --go_out=. --micro_out=. proto/foobar/foobar.proto // 生成protoc 文档 (1.)下载protoc-gen-doc二进制到/usr/local/bin 阅读全文
posted @ 2021-05-27 13:29 苍山落暮 阅读(5542) 评论(0) 推荐(0) 编辑
摘要: 协程数量控制 在Golang中,Goroutine虽然很好,但是数量太多了,往往会带来很多麻烦,比如耗尽系统资源导致程序崩溃,或者CPU使用率过高导致系统忙不过来。所以我们可以限制下Goroutine的数量,这样就需要在每一次执行go之前判断goroutine的数量,如果数量超了,就要阻塞go的执行 阅读全文
posted @ 2021-05-23 23:40 苍山落暮 阅读(3930) 评论(0) 推荐(1) 编辑
摘要: golang context携带值传递 package main import ( "context" "fmt" "google.golang.org/grpc/metadata" ) // 使用context.WithValue()和Value()方法获取值 func GetContextVal 阅读全文
posted @ 2021-05-20 13:12 苍山落暮 阅读(2339) 评论(0) 推荐(0) 编辑
摘要: golang zip压缩 // Package utils zip操作 package utils import ( "archive/zip" "fmt" "io" "log" "os" "path/filepath" "strings" ) // Zip 压缩文件 //nolint func Z 阅读全文
posted @ 2021-05-20 13:06 苍山落暮 阅读(357) 评论(0) 推荐(0) 编辑
摘要: golang GRPC mock 1.)前置条件 go install github.com/golang/protobuf/protoc-gen-go go install github.com/carvalhorr/protoc-gen-mock 2.) 生成mock文件 proto文件gree 阅读全文
posted @ 2021-05-14 08:57 苍山落暮 阅读(1298) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 54 下一页