我想配置go调试env属性,如下所示
DEV_PROP=
'{
"run": "app.sh",
"server_port": "8081",
"app_url":"http://localhost:3000"
}'我试图在env中输入以下内容,但我得到了错误
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
},当我将DEV_PROP插入env对象时,我得到了很多错误,我尝试过玩配额,但没有成功,知道吗?
发布于 2017-11-06 20:46:14
你试过这条路吗?
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"run": "app.sh",
"server_port": "8081",
"app_url":"http://localhost:3000"
},如图所示,http://techbrij.com/visual-studio-code-tasks-debugging
此外,按照约定,环境变量应该都是UPPER_CASE,如下面所示,https://stackoverflow.com/a/673940/6314736
所以应该是这样的:
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"RUN": "app.sh",
"SERVER_PORT": "8081",
"APP_URL":"http://localhost:3000"
}
}另外,如果您希望为dev环境单独启动,只需复制此对象并将"name“属性更改为任何您喜欢的属性。它应该在配置数组中。
正如编辑所指出的,我对这个问题的回答是错误的。正确的答案是用反斜杠转义双引号。"env":{ "DEV_PROP":"\"run\":\"app.sh\",\"server_port\":\"8081\",\"app_url\":\"http ://localhost:3000\"}" }
我测试过了,效果很好。图片作为证明
https://stackoverflow.com/questions/47145313
复制相似问题