摘要: Json转struct例子: 注意json里面的key和struct里面的key要一致,struct中的key的首字母必须大写,而json中大小写都可以。 package main import ( "fmt" "encoding/json" ) type People struct { Name 阅读全文
posted @ 2021-08-19 20:43 码农骆驼 阅读(397) 评论(0) 推荐(0) 编辑
摘要: go get -u gopkg.in/mgo.v2 package main import ( "log" "time" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) const ( MongoDBHosts = "127.0.0.1:27017" AuthD 阅读全文
posted @ 2021-08-19 17:27 码农骆驼 阅读(757) 评论(1) 推荐(0) 编辑
摘要: golang 使用 “gopkg.in/mgo.v2” 查询mongo总结。mongo的增加,更新和删除操作比较简单,查询操作相对灵活复杂一些,下面对golang 查询 mongo 做个总结。完整代码上传到了 https://gitee.com/truthalone/go-mongo.git 。 1 阅读全文
posted @ 2021-08-19 16:07 码农骆驼 阅读(2682) 评论(0) 推荐(1) 编辑
摘要: func getJSON(vehicleType string, sqlString string) (string, error) { rows, err := mysql.GetDB(vehicleType).Query(sqlString) if err != nil { return "", 阅读全文
posted @ 2021-08-19 15:27 码农骆驼 阅读(425) 评论(0) 推荐(0) 编辑
摘要: logrus日志使用详解 参考 https://blog.csdn.net/wslyk606/article/details/81670713 1.logrus特点golang标准库的日志框架很简单,logrus框架的特点:1)完全兼容标准日志库六种日志级别:debug, info, warn, e 阅读全文
posted @ 2021-08-19 14:17 码农骆驼 阅读(2053) 评论(0) 推荐(0) 编辑