profclems / go-dotenv

A fast and minimalist library for loading .env files in Go. Zero Allocation Get and Set methods
MIT License
22 stars 3 forks source link

Undefined Function #3

Open gaby opened 1 month ago

gaby commented 1 month ago

@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()
profclems commented 3 weeks ago

@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
gaby commented 3 weeks ago

@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 commented 3 weeks ago

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