magiconair / properties

Java properties scanner for Go
BSD 2-Clause "Simplified" License
323 stars 77 forks source link

MustGetString documentation is misleading #64

Closed gopherlife closed 2 years ago

gopherlife commented 2 years ago

Hello everyone.

I was testing some code that utilizes the MustGetString function, but was confused when the tests were failing when I was asserting a panic to happen.

I dug into the code and found that it doesn't actually panic, but calls log.Fatal through your ErrorHandler. It would have saved me a lot of time if I knew this from the function's documentation.

I can make the changes myself, but I wanted to see if I am incorrect in my thinking that the documentation is inaccurate first.

Current Documentation: MustGetString returns the expanded value for the given key if exists or panics otherwise.

Proposed Change: MustGetString returns the expanded value for the given key if exists or calls log.Fatal otherwise.

gopherlife commented 2 years ago

Just found out that you can manually set the ErrorHandler to panic instead of calling log.Fatal. Guess I should RTFM before posting issues, sorry about that...