- 首页
- 专栏
-
go modules 初体验
之前有知道dep,vendor,glide等go的包管理方案,但没怎么用起来,modules是官方推出,看势头在后面的版本中也会持续改进,值得尝试。 modules modules在go的1.11版本中加入,并在Go 1.13中对模块进行了重大改进和更改。 开启模块 1.13版本前请务必开启模块 export GO111MODULE=auto 初始化 在你的项目目录中执行: go mod init 13sai/game 会生成go.mod module 13sai/game go 1.12 然后...
-
golang的defer精析
example1 func f() (result int) { defer func() { result++ }() return 0 } example2 func f() (r int) { t := 5 defer func() { t = t + 5 }() return t } example3 func f() (r int) { defer func(r...