随笔分类 -  开发语言 / B-语言之Go

摘要:############################# 问题 checking for iconv support... yes checking for iconv... yes checking if iconv is glibc's... yes checking if iconv sup 阅读全文
posted @ 2023-04-30 22:07 igoodful 阅读(131) 评论(0) 推荐(0) 编辑
摘要:################################# 返回子串的位置:func Index(s, substr string) int #################################### 阅读全文
posted @ 2021-07-16 10:32 igoodful 阅读(92) 评论(0) 推荐(0) 编辑
摘要:############################## go build --ldflags “-s -w ” -o myexe main.go -X importpath.name=value 编译期设置变量的值 -s disable symbol table 禁用符号表 -w disabl 阅读全文
posted @ 2021-07-13 11:56 igoodful 阅读(481) 评论(0) 推荐(0) 编辑
摘要:################################################# 代码位置:https://github.com/chaosblade-io/chaosblade-exec-os.git 文件位置:chaosblade-exec-os/exec/bin/burnio 阅读全文
posted @ 2021-06-24 16:41 igoodful 阅读(182) 评论(0) 推荐(0) 编辑
摘要:############# func (c *multiBankClient) DumpState(ctx context.Context) (interface{}, error) { txn, err := c.db.Begin() if err != nil { return nil, err 阅读全文
posted @ 2021-05-31 10:09 igoodful 阅读(233) 评论(0) 推荐(0) 编辑
摘要:############################# 错误写法: var DB *sql.DB func init() { DB, err := sql.Open("mysql", "tmp:tmp@tcp(10.10.10.10:3306)/mysql") if err != nil { r 阅读全文
posted @ 2021-05-28 11:20 igoodful 阅读(620) 评论(1) 推荐(0) 编辑
摘要:####################### 在实际的业务种,我们可能会有这么一种场景:需要我们主动的通知某一个goroutine结束。比如我们开启一个后台goroutine一直做事情,比如监控,现在不需要了,就需要通知这个监控goroutine结束,不然它会一直跑,就泄漏了。 我们都知道一个go 阅读全文
posted @ 2021-05-14 10:58 igoodful 阅读(330) 评论(0) 推荐(0) 编辑
摘要:######################### 控制并发有两种经典的方式,一种是WaitGroup,另外一种就是Context,今天我就谈谈Context。 什么是WaitGroup WaitGroup以前我们在并发的时候介绍过,它是一种控制并发的方式,它的这种方式是控制多个goroutine同 阅读全文
posted @ 2021-05-14 10:30 igoodful 阅读(89) 评论(0) 推荐(0) 编辑
摘要:########################## 纳秒级别时间: const ( Nanosecond Duration = 1 Microsecond = 1000 * Nanosecond Millisecond = 1000 * Microsecond Second = 1000 * Mi 阅读全文
posted @ 2021-04-19 11:06 igoodful 阅读(50) 评论(0) 推荐(0) 编辑
摘要:############################# package main import ( "fmt" "time" ) // 规则一 当defer被声明时,其参数就会被实时解析 // 规则二 多个defer执行顺序:defer执行顺序为先进后出 // 规则三 defer可以读取有名返回 阅读全文
posted @ 2021-04-16 14:34 igoodful 阅读(132) 评论(1) 推荐(0) 编辑
摘要:############################ 问题参考: https://github.com/golang/go/issues/42255 https://github.com/golang/go/issues/42081 解决办法: 1,在windows的任务管理器里面杀掉所有go. 阅读全文
posted @ 2021-04-12 16:56 igoodful 阅读(3194) 评论(0) 推荐(0) 编辑
摘要:############################# 更换或升级了golang后,需要删除go.mod、go.sum、vendor文件,然后重建,不然一直卡在那里 使用: Go modules 操作命令及相关文件解读 可以命令行执行 go help mod 打印出 go mod 相关命令: d 阅读全文
posted @ 2021-04-09 17:59 igoodful 阅读(1631) 评论(3) 推荐(0) 编辑
摘要:####################### vscode的插件默认安装位置 : C:\Users\你的用户名\.vscode\extensions ###################### 阅读全文
posted @ 2021-04-09 17:56 igoodful 阅读(237) 评论(0) 推荐(0) 编辑
摘要:###################### { "tabnine.experimentalAutoImports": true, "files.autoSave": "off", "[go]": { "breadcrumbs.showArrays": true, "breadcrumbs.show 阅读全文
posted @ 2021-04-09 17:44 igoodful 阅读(1271) 评论(0) 推荐(0) 编辑
摘要:########################### { "version": "0.2.0", "configurations": [ { "name": "Launch file", "type": "go", "request": "launch", "mode": "debug", //" 阅读全文
posted @ 2021-04-09 17:11 igoodful 阅读(983) 评论(0) 推荐(0) 编辑
摘要:########################### golang版本:1.5 环境变量: GOROOT= GOPATH= PATH= GO15VENDOREXPERIMENT=1 #在go1.5版本后必须配置 最开始的时候,Go 并没有提供较为妥当的包管理工具。从 1.5 版本开始提供了 ven 阅读全文
posted @ 2021-04-09 15:45 igoodful 阅读(466) 评论(1) 推荐(0) 编辑
摘要:如果按照上面的方式来读取,读取到第三行,handle,state均为0,原因就在rows.Scan读取数据库null是报错,导致后面的不执行。解决方法有两个方法一:修改结构体将ListHelperAssignRsp的Handle的类型改为sql.NullString,这样就可以兼容null跟stri 阅读全文
posted @ 2021-02-24 17:19 igoodful 阅读(789) 评论(0) 推荐(0) 编辑
摘要:################################## 区别于C/C++中的指针,Go语言中的指针不能进行偏移和运算,是安全指针。 go什么情况下使用指针: 推荐在方法上使用指针(前提是这个类型不是 map、slice 等引用类型) 当结构体较大的时候使用指针会更高效,可以避免内存拷贝 阅读全文
posted @ 2021-02-20 15:33 igoodful 阅读(159) 评论(0) 推荐(0) 编辑
摘要:############################ ########################## 阅读全文
posted @ 2020-12-08 16:38 igoodful 阅读(128) 评论(29) 推荐(0) 编辑
摘要:############## 地址:https://github.com/gorilla/mux 安装 go get -u github.com/gorilla/mux 使用 添加包引用: "github.com/gorilla/mux" 常用方法介绍 初始化路由 r := mux.NewRoute 阅读全文
posted @ 2020-12-08 11:27 igoodful 阅读(231) 评论(0) 推荐(0) 编辑

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