You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In many application we use environment variables for things such as API keys, database connection credentials, and so on.
Many times we wish to get an environment variable and ensure it is not empty, otherwise the application immediately, but since we can't check that outside a function, we do something like this:
I know it is something trivial to implement by your own in your projects, but Go stdlib has many functions that are trivial to implement but very useful at the same time.
The text was updated successfully, but these errors were encountered:
@seankhliao Although they are similar, I wouldn't say it is a duplicate.
The other proposal is about "generic must", while this is a specific use case for environment variables.
In many application we use environment variables for things such as API keys, database connection credentials, and so on.
Many times we wish to get an environment variable and ensure it is not empty, otherwise the application immediately, but since we can't check that outside a function, we do something like this:
Since many applications can't run without some env variables and would rather prefer to "fail first", sounds reasonable to me a function like this:
I know it is something trivial to implement by your own in your projects, but Go stdlib has many functions that are trivial to implement but very useful at the same time.
The text was updated successfully, but these errors were encountered: