#Current working directory

4 messages · Page 1 of 1 (latest)

stable zenith
#

I have a query about how golang decides what is the current working directory. I have a .env file in the root directory and I have some pakages in the sub-directories of the project. When I run tests that are located in the sub-directories the godotenv package is trying to load .env file from the file's location i.e. the subdirectory instead of the root directory from where i run the tests. Is this expected behavior? What is the solution here?

#

Another thing is i tried using source .env and then running os.Getenv without loading with godotenv

#

it doesn't work which is super weird

#

but when i do echo $ENV_NAME i get my value