Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

How to set env var before run Go test command #475

Closed
ysqi opened this issue Sep 13, 2016 · 7 comments · Fixed by #498
Closed

How to set env var before run Go test command #475

ysqi opened this issue Sep 13, 2016 · 7 comments · Fixed by #498

Comments

@ysqi
Copy link

ysqi commented Sep 13, 2016

hi, Need use env var in go test , So I want to add Environment Variables just for go test command.
how to do it ? thanks!
Go: Run test at cursor

@lukehoban
Copy link
Member

I don't think there's any way to do this currently. Currently the extension just uses the environment that VS Code was launched with. PRs for a new configuration option to specify additional env vars to pass through to the go test invocation welcome.

@ramya-rao-a
Copy link
Contributor

Setting env variables via the configuration settings for the tests to use would apply the same env vars to all tests in the project.
Would that be the most common scenario or different tests needing different env vars be more common?
If it is the latter, we can prompt the user for entering the env vars when the test commands are triggered. And whether to prompt or not can be controlled via the configuration settings

@ysqi
Copy link
Author

ysqi commented Sep 19, 2016

thanks @lukehoban @ramya-rao-a ,I want to use env variables for all tests in current workspace.
but can't setting env variables via the configuration settings now.
e.g init run mode ,first check Is there a set env var runMode . different run mode use different config. runMode=test => config= app.test.config .

@ramya-rao-a
Copy link
Contributor

@ysqi , Just to clarify ..

e.g init run mode ,first check Is there a set env var runMode . different run mode use different config. runMode=test => config= app.test.config

What you mean is in your case you would like to set an env var "runMode" and based on its value your tests would use different configs correct?

And not that you would like a feature where vscode picks up different config files based on the runMode setting

@ysqi
Copy link
Author

ysqi commented Sep 21, 2016

@ramya-rao-a the config file is that my application's file, not about vscode.

@ramya-rao-a
Copy link
Contributor

@ysqi This feature is now available in the latest version of the Go extension : 0.6.44

@ernsheong
Copy link

I ran into this. Thank you so much!! 🙌 🙌

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants