I want to configure go debug env json properties like following
DEV_PROP=
'{
"run": "app.sh",
"server_port": "8081",
"app_url":"http://localhost:3000"
}'
Ive tried to enter the following to the env but I got error
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
},
when I insert the DEV_PROP to the env object I got lots of error, ive tried to play with quotas without success, any idea?
Did you try this way?
{
"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"
},
As shown here http://techbrij.com/visual-studio-code-tasks-debugging
Also by convention environment variables should be all UPPER_CASE as shown here https://stackoverflow.com/a/673940/6314736
So it should look like that:
{
"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"
}
}
Also if you want to have separate launch for dev environment just copy this object and change "name" property to whatever you like. It should be in Configuration array.
EDIT As Adrian pointed out, my answer to this question was wrong. The correct answer is to escape double quotes with backslashes. "env":{ "DEV_PROP":"\"run\":\"app.sh\",\"server_port\":\"8081\",\"app_url\":\"http ://localhost:3000\"}" }
I've tested it and it works fine. Picture for proof