这是我的tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "login",
"type": "shell",
"command": "go run main.go login",
"options": {
"env": {
"dbConnectionString": "host=localhost port=5431 user=user dbname=db password=pass sslmode=disable",
"spotifyClientID": "some-value",
"spotifyClientSecret": "another-value"
}
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "getPlaylists",
"type": "shell",
"command": "go run main.go getPlaylists",
"options": {
"env": {
"dbConnectionString": "host=localhost port=5431 user=user dbname=db password=pass sslmode=disable",
"spotifyClientID": "some-value",
"spotifyClientSecret": "another-value"
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
我不想在每个任务中复制粘贴相同的环境变量。也许有一种方法可以在一处定义所有环境变量,然后在每个任务中重用它们?
答案 0 :(得分:0)
此配置对我有用:
{ "version": "2.0.0",
"options":{
"env":{}
},
"tasks": [ ]
}