上一页 1 2 3 4 5 6 7 ··· 21 下一页
摘要: type Season int const ( Summer Season = iota + 1 Autumn Winter Spring ) type ArticleState int const ( Draft ArticleState = iota + 1 Published Deleted 阅读全文
posted @ 2023-02-13 14:14 ☞@_@ 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 1、安装 go get -u github.com/swaggo/swag/cmd/swag go get -u github.com/swaggo/gin-swagger go get -u github.com/swaggo/files go get -u github.com/alecthom 阅读全文
posted @ 2022-12-11 15:24 ☞@_@ 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 1、文件目录 2、代码 主要分为两步: 1)定义子命令 wordCmd = &cobra.Command{。。。。。。} 2)将子命令添加进根命令 rootCmd.AddCommand(wordCmd) cmd/word.go package cmd import ( "log" "strings" 阅读全文
posted @ 2022-11-24 16:44 ☞@_@ 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 1、 flag 基本使用和长短选项 package main import ( "flag" "fmt" ) func main() { var name string flag.StringVar(&name, "name", "Go 语言编程之旅", "帮助信息") flag.StringVar 阅读全文
posted @ 2022-11-24 15:50 ☞@_@ 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 1、kitex的支持的编解码协议 (1)目前,Kitex 支持了 thrift 和 protobuf 两种编解码协议。 (2)thrift编解码 生成代码时可以不指定 thrift 协议,默认就是 thrift。 //生成客户端代码 kitex -type thrift ${service_name 阅读全文
posted @ 2022-10-26 15:07 ☞@_@ 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 1、安装依赖 安装 kitex和thriftgo go install github.com/cloudwego/kitex/tool/cmd/kitex@latest​ ​go install github.com/cloudwego/thriftgo@latest 2、相关概念 (1)Kitex 阅读全文
posted @ 2022-10-26 14:22 ☞@_@ 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 1、linux系统安装kitex工具还是报错command not found // 找到etc/profile文件,输入如下(path是kitex的安装目录) export PATH=$PATH:/root/goCode/bin // 更新配置 source /etc/profile 参考:(36 阅读全文
posted @ 2022-10-26 10:41 ☞@_@ 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 参考:linux 安装consul - 简书 (jianshu.com) 阅读全文
posted @ 2022-10-22 10:17 ☞@_@ 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 1、信号传递 有 4 个 goroutine,编号为 1、2、3、4。每秒钟会有一个 goroutine 打印出它自己的编号,要求你编写程序,让输出的编号总是按照 1、2、3、4、1、2、3、4……这个顺序打印出来。 type Token struct{} func newWorker(id int 阅读全文
posted @ 2022-10-21 09:52 ☞@_@ 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1、golang的持久化连接 在Golang中使用持久化连接发起HTTP请求,主要依赖Transport,官方封装的net库中已经支持。 Transport实现了RoundTripper接口,该接口只有一个方法RoundTrip(),故Transport的入口函数就是RoundTrip()。 Tra 阅读全文
posted @ 2022-10-20 10:50 ☞@_@ 阅读(236) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 21 下一页