When I use VSCODE in my Ubuntu 16.10 to compile my go project, it can't succeed and prompt:
compile: cannot disable optimizations while compiling runtime
exit status 2
Process exiting with code: 1
I checked my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"GOPATH":"/home/bill/test/go",
"GOROOT":"/usr/local/go"
},
"args": [],
"showLog": true
}
]
}
What can I do to change this?
This error message seems to come from the Go compiler due to this change which fixes this bug (the "compile: " prefix is apparently added by vscode).
My take on the reason is as follows:
As to how to solve this, I have no clean idea. Supposedly running
$ cd /usr/local/go/src
$ ./make.bash
should do it.
On a side note, you must not set the GOROOT
env. variable by hand—please leave it to the Go suite instead; since many versions ago, it knows its GOROOT
automatically based on where the go
binary is located.