随笔分类 -  go

go语言相关
摘要:常见问题 1.IndexError: list index out of range 1.一般出现死循环,排查数据迭代节点 2.数据量较大,排查数据量 阅读全文
posted @ 2021-08-16 17:17 jiuchen 阅读(29) 评论(0) 推荐(0) 编辑
摘要:时分秒互转 //秒转成时分秒 func C1(sec int) string { var h, m, s int s = sec % 60 h = sec / (60 * 60) m = (sec - h*60*60) / 60 return fmt.Sprintf("%v时%v分%v秒", h, 阅读全文
posted @ 2021-07-22 16:51 jiuchen 阅读(29) 评论(0) 推荐(0) 编辑
摘要:理解 1.需要读同一份数据,使用单例 2.需要读写同一份数据单例+锁达到线程安全 测试代码 package code import "sync" /** * 使用结构体代替类 */ type Tool struct { values int } /** * 建立私有变量 */ var instanc 阅读全文
posted @ 2021-07-22 10:20 jiuchen 阅读(147) 评论(0) 推荐(0) 编辑
摘要:多参数排序 package code import "sort" type CanRow struct { CANChannel string `json:"can_channel"` CANBUSID string `json:"canbusid"` SignalName string `json 阅读全文
posted @ 2021-07-16 09:45 jiuchen 阅读(29) 评论(0) 推荐(0) 编辑
摘要:测试用例 package code import ( "github.com/shopspring/decimal" ) //float64转成int64 func Float64ToInt64(s interface{}) int64 { var data int64 if s != nil { 阅读全文
posted @ 2021-07-08 09:48 jiuchen 阅读(22) 评论(0) 推荐(0) 编辑
摘要:定义 服务发现与注册 阅读全文
posted @ 2021-03-07 14:43 jiuchen 阅读(39) 评论(0) 推荐(0) 编辑
摘要:定义 微服务工具集 自动生成结构 https://github.com/GrantZheng/kit 阅读全文
posted @ 2021-03-07 14:41 jiuchen 阅读(84) 评论(0) 推荐(0) 编辑
摘要:相关 阅读全文
posted @ 2021-03-07 10:30 jiuchen 阅读(28) 评论(0) 推荐(0) 编辑
摘要:docker pul consul docker run -d --name=cs -p 8500:8500 consul 阅读全文
posted @ 2021-03-06 18:44 jiuchen 阅读(51) 评论(0) 推荐(0) 编辑
摘要:启动报错 panic: qtls.ConnectionState not compatible with tls.ConnectionState 解决:用低于1.15的go就行了 阅读全文
posted @ 2021-03-06 17:34 jiuchen 阅读(650) 评论(0) 推荐(0) 编辑
摘要:微信开发 https://github.com/silenceper/wechat 定时 github.com/robfig/cron excel处理 github.com/tealeg/xlsx 阅读全文
posted @ 2020-09-02 08:27 jiuchen 阅读(413) 评论(1) 推荐(0) 编辑
摘要:gin中文件流导出excel func GoodsExport(c *gin.Context) { var list []GoodsExports dbMysql := mysql.GetORM() sql := `select goods_id,user_id,goods_name from tb 阅读全文
posted @ 2020-08-19 16:34 jiuchen 阅读(1361) 评论(0) 推荐(0) 编辑
摘要:go-xorm package main import ( "fmt" _ "github.com/go-sql-driver/mysql" "github.com/go-xorm/xorm" //xorm原版 "github.com/shopspring/decimal" "github.com/ 阅读全文
posted @ 2020-07-27 13:22 jiuchen 阅读(174) 评论(0) 推荐(0) 编辑
摘要:上下文设置变量 package main import ( "fmt" "github.com/gin-gonic/gin" "time" ) func MiddleWare() (gin.HandlerFunc){ return func(c *gin.Context) { t:=time.Now 阅读全文
posted @ 2020-07-10 14:46 jiuchen 阅读(270) 评论(0) 推荐(0) 编辑
摘要:验证规则:https://github.com/go-playground/validator 中文参考:https://www.cnblogs.com/zj420255586/p/13542395.html https://www.cnblogs.com/wangkun122/articles/1 阅读全文
posted @ 2020-07-03 15:10 jiuchen 阅读(841) 评论(0) 推荐(0) 编辑
摘要:监听文件变化并重启 方式一 /** 自动重启gin框架文件 执行命令 go run example.go -start main.go **/ package main import ( "flag" "fmt" "github.com/fsnotify/fsnotify" "log" "os" " 阅读全文
posted @ 2020-06-15 21:28 jiuchen 阅读(437) 评论(0) 推荐(0) 编辑
摘要:统计1-1000包含1的数字的个数 //判断1-1000中含1的数字有多少 func catianOne() { num := 0 for i := 1; i <= 1000; i++ { if strings.Contains(strconv.Itoa(i), "1") { num++ fmt.P 阅读全文
posted @ 2020-06-08 14:39 jiuchen 阅读(177) 评论(0) 推荐(0) 编辑
摘要:http请求 hello world package main import ( "fmt" "net/http" ) //创建处理器函数 func handler(w http.ResponseWriter,r *http.Request){ //r.URL.Path路由中的参数 fmt.Fpri 阅读全文
posted @ 2020-02-24 11:26 jiuchen 阅读(383) 评论(0) 推荐(0) 编辑
摘要:数据结构 稀疏数组 package main import "fmt" /* 稀疏数组 案例:五子棋存盘与复盘 节省存储空间 */ type ValNode struct { row int //行 col int //列 val int //值 } //原始数组实现 func normalArra 阅读全文
posted @ 2020-01-17 10:28 jiuchen 阅读(718) 评论(0) 推荐(1) 编辑
摘要:安装 redis参考手册 go get gopkg.in/redis.v4//引入 "gopkg.in/redis.v4" 连接 redis.v4 包实现了 redis 的连接池管理, 因此我们就不需要自己手动管理 redis 的连接了.默认情况下, redis.v4 的 redis 连接池大小是1 阅读全文
posted @ 2020-01-14 14:55 jiuchen 阅读(366) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示