插入调试环境json属性VSCode
我想配置go debug env json属性,如下所示插入调试环境json属性VSCode,json,go,visual-studio-code,Json,Go,Visual Studio Code,我想配置go debug env json属性,如下所示 DEV_PROP= '{ "run": "app.sh", "server_port": "8081", "app_url":"http://localhost:3000" }' 我试着在环境中输入以下内容,但出现了错误 "configurations": [ { "name": "Launch", "type": "go", "request": "launch",
DEV_PROP=
'{
"run": "app.sh",
"server_port": "8081",
"app_url":"http://localhost:3000"
}'
我试着在环境中输入以下内容,但出现了错误
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
},
当我将DEV_道具插入env对象时,我犯了很多错误,我尝试使用配额但没有成功,你知道吗?你是这样尝试的吗
{
"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"
},
如图所示
按照惯例,环境变量应该都是大写的,如下所示
所以它应该是这样的:
{
"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\u PROP”:“run\”:“app.sh\”,“server\u port\”:“8081\”,“app\u url\”:“http
://本地主机:3000\“}”
}
我已经测试过了,效果很好。
不是100%确定,但从问题的编写方式来看,他们想要一个单一的环境变量
DEV_PROP
,其值是他们给出的JSON。哦,是的,你可能是对的。然后可能会用反斜杠转义引号“DEV\u PROP”:“{\“run\”:\“app.sh\”,“server\u port\”:“8081\”,“app\u url\”:\”http://localhost:3000\“}”