go升级遇到问题及解决方案



brew install go
会将新版go安装到 /usr/local/Cellar/go/1.9.2/
$ ls /usr/local/Cellar/go/1.9.2/
AUTHORS LICENSE bin
INSTALL_RECEIPT.json README.md libexec
却少的库和编译工具都在libexec目录下,直接复制src 目录到goroot,虽然能解决找不到库文件的问题,但是会报
go tool: no such tool "compile"
将/usr/local/Cellar/go/1.9.2/libexec 设为gopath
会报
import cycle not allowed
package cmd/dist
imports bytes
imports errors
imports runtime
imports unsafe
imports runtime

解决办法:
go官网下载安装包
https://golang.org/doc/install?download=go1.9.2.darwin-amd64.pkg

Failded to continue:"Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your "GOPATH/bin" or "PATH"

$go get github.com/derekparker/delve/cmd/dlv

多项目调试

在launch.json中可以添加多组调试入口, 通过调试面板中选中对应的配置开启不同目标的调试

{
"version": "0.2.0",
"configurations": [
{
"name": "client",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"GOPATH":"D:/Develop/vscodegolang"
},
"args": [],
"showLog": true
},

{
"name": "server",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/src/server",
"env": {
"GOPATH":"D:/Develop/vscodegolang"
},
"args": [],
"showLog": true
}
]
}


"program"中的"${fileDirname}"是以当前选中文件作为启动点

更建议使用"program"的"${workspaceRoot}", 以包名作为启动点的方式进行配置

Category web