Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
19
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

VSCode 用の launch.json でデバッグコマンドに環境変数 / 引数 / フラグを渡す設定

環境変数を渡す

"env": {
    "FIRST_NAME": "yuma",
    "LAST_NAME": "inaura"
}

以下のような状態でコマンドが走ることになる。

FIRST_NAME=yuma LAST_NAME=inaura command

引数を渡す

"args": ["yuma","inaura"]

以下のようなコマンドが走ることになる。

command yuma inaura

コマンドのフラグを渡す

これも args に指定できる。

"args": ["--first_name=yuma","--last_name=inaura"]

以下のようなコマンドが走ることになる。

command --first_name=yuma --last_name=inaura

ファイル例

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "program": "${workspaceRoot}/some_package/cmd/name",
            "env": {
                "GOPATH": "/Users/yinaura/go",
            },
            "args": ["yuma","--last_name=inaura"],
            "showLog": true
        }
    ]
}

環境

  • VsCode 1.11.2
  • MacOs Sierra 10.12.3
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
19
Help us understand the problem. What are the problem?