上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 34 下一页

【解决了一个小问题】golang samara的kafka客户端中使用错误版本号导致初始化失败

摘要: 发现在如下代码中存储kafka生产者初始化失败: config.Version = sarama.V0_10_2_1 //V2_2_0_0 producer, err := sarama.NewSyncProducer(options.Kafka.KafkaBrokerList, config) i 阅读全文
posted @ 2020-11-30 22:03 ahfuzhang 阅读(4229) 评论(0) 推荐(0)

【解决了一个小问题】golang xorm中使用where id in (xxx),没办法使用参数替换

摘要: 代码中使用XORM来从数据库查询数据,有类似如下的代码: session.Where("id in (?)", strings,Join(arr, ",")) 发现:当arr中的ID个数大于1时,查询不出来任何数据。 于是修改为: session.Where(fmt.Sprintf("id in ( 阅读全文
posted @ 2020-11-16 16:35 ahfuzhang 阅读(1306) 评论(0) 推荐(0)

【记录一个问题】golangci-lint.exe中,盘符大写就会执行出错

摘要: golangci-lint.exe版本为1.31.0 执行:golangci-lint.exe run d:\source\github.com\ahfuzhang\go_xxx_server\src\cgi 正常 执行:golangci-lint.exe run D:\source\github. 阅读全文
posted @ 2020-10-16 16:40 ahfuzhang 阅读(1743) 评论(0) 推荐(0)

windows+goland+gometalinter进行本地代码检查(高圈复杂度、重复代码等)

摘要: 1.下载gometalinter release地址为:https://github.com/alecthomas/gometalinter/releases/tag/v3.0.0 下载windows版本:https://github.com/alecthomas/gometalinter/rele 阅读全文
posted @ 2020-10-13 21:14 ahfuzhang 阅读(840) 评论(0) 推荐(0)

【解决了一个小问题】golang go.mod中多了一个斜杠导致replace无效

摘要: replace github.com/sxxx/common_lib/src/ ⇒ ../../common_lib/src 修改成 replace github.com/sxxx/common_lib/src ⇒ ../../common_lib/src 后,replace才生效了。 阅读全文
posted @ 2020-10-13 14:16 ahfuzhang 阅读(1170) 评论(0) 推荐(0)

【涨姿势】原来golang的case <-time.After(xxx)还有这样的坑

摘要: 偶然看到这样一篇文章:《使用 pprof 排查 Golang 内存泄露》https://www.toutiao.com/i6881796351139676680/ 最后一段让我很疑惑: 修改 for ... select ... time.After 造成的内存泄露 原来程序中存在如下代码: for 阅读全文
posted @ 2020-10-12 21:14 ahfuzhang 阅读(1085) 评论(0) 推荐(0)

【小实验】rust的数组是在堆上分配还是在栈上分配的呢?

摘要: 先看代码: fn main(){ let v = [1,2,3,4,5]; let addr = &v[0] as *const i32 as usize; println!("arr={}, addr=0x{:X}", v.len(), addr); // let top = 1; let add 阅读全文
posted @ 2020-09-14 21:45 ahfuzhang 阅读(990) 评论(0) 推荐(0)

【记录一个问题】go.mod中使用replace后,编译出现神奇的错误:

摘要: biz\child.go:5:2: imported and not used: "xxx.com/start/common/src/polaris" as biz biz\child.go:17:9: undefined: polaris 前面告诉我导入了未使用,后面又告诉我没导入……你到底要我怎 阅读全文
posted @ 2020-09-14 14:29 ahfuzhang 阅读(526) 评论(0) 推荐(0)

【记录一个问题】在goland中的_test.go文件中,点右键点run,无法执行测试用例

摘要: 比较奇怪的是: 在命令行下,用 test -v alloc_test.go -test.run TestAlloc_utilJoinCPUAndGpu alloc.go 可以执行测试用例 比较奇怪的是要把相关的引用的文件都跟在后面,否则出现XX未定义的错误 在goland中,如果不依赖其他类型,点右 阅读全文
posted @ 2020-08-25 16:22 ahfuzhang 阅读(1416) 评论(0) 推荐(0)

golang取地址操作采坑:for idx,item := range arr中的item是个独立对象

摘要: 先看代码: package main import "fmt" func main() { type s struct { A string B int32 } arr := []s{ {"123", 123}, {"456", 456}, {"789", 789}, } m := make(map 阅读全文
posted @ 2020-08-24 17:10 ahfuzhang 阅读(366) 评论(0) 推荐(0)
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 34 下一页