随笔分类 -  golang

golang 使用泛型进行分组排序
摘要:使用golang 泛型编写出一个通用的分组排序 package main type GetSorterNum interface { GetSorterNum() int } func SortInt(list []int) []int { if len(list) > 0 { sort.Slice 阅读全文

posted @ 2024-06-14 15:20 biwentao 阅读(25) 评论(0) 推荐(0) 编辑

golang 切片原理面试题
摘要:package main import "fmt" func main() { var s = make([]int, 0, 10) _ = append(s, 1,2,3) fmt.Println(s) fmt.Println(s[0:cap(s)]) } 第一次打印和第二次打印分别是什么值了? 阅读全文

posted @ 2022-03-22 15:40 biwentao 阅读(143) 评论(0) 推荐(0) 编辑

20220314线上panic总结
摘要:panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x9273ea] gorout 阅读全文

posted @ 2022-03-14 17:23 biwentao 阅读(121) 评论(0) 推荐(0) 编辑

golang 怎样防止结构体对象被拷贝
摘要:主要实现Lock以及Unlock就可以了 此时使用go vet mian.go 检查就会提示我们./main1.go:25:7: assignment copies lock value to b: command-line-arguments.App contains command-line-a 阅读全文

posted @ 2022-03-08 16:48 biwentao 阅读(337) 评论(0) 推荐(0) 编辑

gossh nohup部署退出解决方法
摘要:ssh 会话远程nohup ./node> node.out & 执行指令,会话退出以后也会导致服务并没有部署成功。 应该使用以下命令:nohup ./node > node.out 2>&1 & 阅读全文

posted @ 2021-12-22 10:39 biwentao 阅读(195) 评论(0) 推荐(0) 编辑

json 编码后导致数字变为科学计数,从而导致解码后签名与编码前签名不正确的解决办法。
摘要:docoder := json.NewDecoder(strings.NewReader(string(originData))) docoder.UseNumber() _ = docoder.Decode(&targetData) 直接解码的时候就禁用科学计数法 阅读全文

posted @ 2021-08-11 11:22 biwentao 阅读(522) 评论(0) 推荐(0) 编辑

golang http client 长连接vs短连接基准测试
摘要:package main import ( "io/ioutil" "net/http" "strings" "testing" ) func KeepAlive(client *http.Client) { req, err := http.NewRequest("GET", "http://lo 阅读全文

posted @ 2021-05-07 14:32 biwentao 阅读(719) 评论(0) 推荐(0) 编辑

Go 指针逃逸分析
摘要:引用 https://my.oschina.net/renhc/blog/2222104 阅读全文

posted @ 2021-01-08 13:42 biwentao 阅读(206) 评论(0) 推荐(0) 编辑

go 通过指针修改结构体小写字段的值
摘要:package main import ( "fmt" "unsafe" ) type W struct { b int32 c int64 } func main() { var w = W{} //这时w的变量打印出来都是默认值0,0 fmt.Println(w.b,w.c) //现在我们通过指 阅读全文

posted @ 2021-01-08 09:42 biwentao 阅读(365) 评论(0) 推荐(0) 编辑

go append的坑
摘要:b := []int{1,2,3,4,5} slice := b[:2] newSlice := append(slice, 50) fmt.Println(b) fmt.Println(newSlice) 打印: [1 2 50 4 5] [1 2 50] append 底层源码实现如果发现切片指 阅读全文

posted @ 2021-01-06 17:56 biwentao 阅读(165) 评论(0) 推荐(0) 编辑

go 基数排序
摘要:package main import ( "fmt" ) func SelectSortMax(arr []int) int { arrLen := len(arr) if arrLen <= 1 { return arr[0] }else { max := arr[0] for i, _ := 阅读全文

posted @ 2021-01-05 23:02 biwentao 阅读(129) 评论(0) 推荐(0) 编辑

go goroutine pool设计
摘要:推荐一遍由浅入深简绍goroutine pool设计的方案。https://strikefreedom.top/high-performance-implementation-of-goroutine-pool 阅读全文

posted @ 2020-12-10 16:34 biwentao 阅读(80) 评论(0) 推荐(0) 编辑

DevOps+Go
摘要:转载 https://blog.csdn.net/qq_20867981/article/details/88846687 阅读全文

posted @ 2020-06-28 20:16 biwentao 阅读(115) 评论(0) 推荐(0) 编辑

go encoding/json 替代者
摘要:https://github.com/json-iterator/go 可以替代官方包encoding/json 提升json编码和解码效率 阅读全文

posted @ 2020-06-26 18:21 biwentao 阅读(181) 评论(0) 推荐(0) 编辑

转载go如何优雅的处理错误值
摘要:https://www.cnblogs.com/Jun10ng/p/12708691.html 阅读全文

posted @ 2020-05-31 21:05 biwentao 阅读(146) 评论(0) 推荐(0) 编辑

beego go mod 模式下无法生成注解路由的问题 解决方法
摘要:执行 go get github.com/beego/bee 命令时将bee 命令一定要安装在gopath目录下.有idea或者goland编辑器是最方便的,只需要复制这条命令,然后进入编辑器会提示你安装,这时只需要 add gopath就行,千万不要add moudle。 阅读全文

posted @ 2020-03-01 19:58 biwentao 阅读(1162) 评论(0) 推荐(0) 编辑

golang nsq 同一个topic有多个channel,同时项目又互相引用时出现的问题
摘要:同一个topic下 不同channel分多个项目的时候,如果一个项目引用了别的项目包(这两个项目连的是同一个topic),那么被引用的项目就需要手动初始化mq,不能使用Init,因为会导致mq初始化两次,在一个channel下链接了两个消费者导致mq进行了负载均衡. 阅读全文

posted @ 2020-01-11 11:15 biwentao 阅读(520) 评论(0) 推荐(0) 编辑

golang 后台 苹果一键登录 sing in with apple
摘要:本文主要展示golang后台编写苹果一键登录的代码.苹果一键登录的流程需自行去查看相关文档 这是解析 identity_token的方法来验证 如果是用code的话验证 请去 https://blog.csdn.net/tptpppp/article/details/99288426 也是得到苹果的 阅读全文

posted @ 2020-01-11 11:12 biwentao 阅读(2136) 评论(0) 推荐(1) 编辑

go 交叉编译遇到的错误, 有路由方法却找不到。
摘要:panic: 'OrderCancel' method doesn't exist in the controller Controller今天线下能正常编译,到线上却panic了。发现是自己导入了import C由于线下环境完善,所以能正常编译,而线上没有cgo编译器,所以不能正常编译。只需将这个 阅读全文

posted @ 2019-08-16 10:50 biwentao 阅读(467) 评论(0) 推荐(0) 编辑

转 [golang]为什么Response.Body需要被关闭
摘要:Body io.ReadCloser Body io.ReadCloser The http Client and Transport guarantee that Body is always non-nil, even on The http Client and Transport guara 阅读全文

posted @ 2019-07-31 09:20 biwentao 阅读(340) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示