-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: Getenv() don't work when it has more than 1 env inside #60867
Comments
CC @golang/windows |
have you checked that your shell has actually set the environment variables correctly? |
I don't have any idea about what you said. If you mean in .env file there is no empty space right of the lines i checked it. |
how does a line in your .env file get into your shell? Go doesn't read .env files. Did your shell pick up the your config? Which shell/platform combination is this running on? how is your program executed? |
I'm executed program with "go run main.go" command. I'm using Visual Studio Core Insiders, and i don't know anything about "shell". |
closing as I don't think this is a bug in Go, rather it is in whatever thing that sources the lines from your file into the environment. |
Hello, i'm using go v1.20.4 and os.Getenv function don't work when it has more than 1 variable inside it.
.env file looks like this:
When i find that bug, i make some tests like this:
And i take this Promt in the terminal:
localAddr: false
websiteAddr: false
environment: false
Normally, i should use environment variables but i don't know why i cant if they are more than 1. This also happened when i try to write the values without quotes. I'm using Windows 11 and Visual Studio Code.
Update: It's Solved
First, I'm solved it with giving env variables to empty string on .env file:
Later than that i use
os.Setenv()
functions for each variable:And i take this prompt on terminal:
localAddr: true
websiteAddr: true
environment: true
So, why this weird thing happened from beginning? Why i have to set this variables manually?
The text was updated successfully, but these errors were encountered: