Is there any way to set environment variables in Visual Studio Code?

前端 未结 8 1168
眼角桃花
眼角桃花 2020-12-04 17:26

Could you please help me, how to setup environment variables in visual studio code?

8条回答
  •  眼角桃花
    2020-12-04 18:02

    For more advanced Go language scenarios, you can load an environment file, like this:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Launch",
          "type": "go",
          "request": "launch", 
          "mode": "debug",
          "remotePath": "",
          "port": 2345,
          "host": "127.0.0.1",
          "program": "${workspaceFolder}",
          "envFile": "${workspaceFolder}/.env",
          "args": [], 
          "showLog": true
        }
      ]
    }
    

    Place the .env file in your folder and add vars like this:

    KEY1="TEXT_VAL1"
    KEY2='{"key1":val1","key2":"val2"}'
    

    Details: https://medium.com/@reuvenharrison/using-visual-studio-code-to-debug-a-go-program-with-environment-variables-523fea268271

提交回复
热议问题