go-dotenv icon indicating copy to clipboard operation
go-dotenv copied to clipboard

Undefined Function

Open gaby opened this issue 1 year ago • 3 comments

@profclems I havent been able to update to v1.0.0 since a few functions are missing.

For example LoadConfig(). If you look at the test, they dont even call this funcion that's mentioned in the README.

See here: https://github.com/profclems/go-dotenv/blob/main/bench_test.go#L9

Using the following results in a panic:

cfg := dotenv.New()
cfg.SetConfigFile("/path/to/file")
cfg.Load()

gaby avatar Sep 17 '24 12:09 gaby

@gaby is it possible that you're using the global instance somewhere in the codebase?

As at v1.0.0, if you're using the global instance, you need to load with:

dotenv.Load()

If you're setting the path:

dotenv.SetConfigFile("/path/to/file")
dotenv.Load()

// then you can do dotenv.Get* anywhere in the code

profclems avatar Oct 12 '24 02:10 profclems

@profclems All I did was update the version, and change to the code from my original post, and it throws an exception now.

The readme needs to be updated, LoadConfig() is undefined: https://github.com/search?q=repo%3Aprofclems%2Fgo-dotenv%20LoadConfig&type=code

gaby avatar Oct 12 '24 02:10 gaby

@profclems I have multiple global instances, but they have different names though. I'm loading multiple .env files.

gaby avatar Oct 12 '24 02:10 gaby