
GOLANG
文章平均质量分 59
woshiyuanlei
精通服务器架构,网络通信,数据库操作,熟悉操作系统原理
展开
-
go test 使用 和 我遇到的坑
网上很多go test的教程,但是写得都不好,尤其对新手不友好。现在同目录下有两个文件:calc.go 和 calc_test.go,现在就来讲一讲具体操作。calc.go 内容如下package mainfunc Add(a int, b int) int { return a + b + 1}func Mul(a int, b int) int { return a * b}func GetSumOut(n int) (sum int) { for i :原创 2021-03-25 16:42:28 · 1379 阅读 · 0 评论 -
golang相关,包括go mod 使用第三方包和自己本地开发的包
一. 环境配置go env -w GO111MODULE=ongo env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct二. go mod 使用 在系统任意目录下建立gomodtest目录,而不需要把gomodtest放到GOPATH目录下。 1. cmd 到当前gomodtest目录下,运行 go mod init gomodtest 2. 建立main文件,内容如下:package ma...原创 2021-04-06 11:23:55 · 3951 阅读 · 1 评论 -
golang的defer精析
example1func f() (result int) { defer func() { result++ }() return 0}example2func f() (r int) { t := 5 defer func() { t = t + 5 }() return t}exam...转载 2018-04-23 16:38:05 · 257 阅读 · 0 评论 -
Golang继承,指针与非指针的区别
package mainimport "fmt"import "time"type cc interface{ MyPrint() MyPrint2()}type cc1 struct{ a int}type cc2 struct{ *cc1}type cc3 struct{ cc1}func(c *cc1)MyPrint(){ f...原创 2018-05-15 14:12:49 · 2715 阅读 · 0 评论 -
使用DLV调试Go语言的核心转储(Core Dumps)
调试Go语言的核心转储(Core Dumps)delve coredump 调试工具 golang4.6k 次阅读 · 读完需要 11 分钟1翻译原文链接转帖/转载请注明出处英文原文链接【Go, the unwritten parts】发表于2017/05/22 作者JBD是Go语言开发小组成员检查程序的执行路径和当前状态是非常有用的调试手段...转载 2019-09-10 23:54:47 · 1625 阅读 · 0 评论 -
go tool pprof 使用
package mainimport "sync"import "time"import "fmt"import ( "runtime" "runtime/debug" "runtime/pprof" "os" "strings" "strconv")type myLocker sync.Lockervar ( progname string)func in...原创 2019-09-26 01:11:58 · 2042 阅读 · 0 评论