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