by jtwaleson · 3y ago · 0 comments
For example in a code base I work in, docker-compose uses it, laravel picks up the same file and Vue / webpack does too. It's a big mess. There must be better solutions out there.
It kind of is, environment variables can only be strings, so why "type" it when you 100% know that everything within is 100% a String, always?
Strings are fine for keys and verbatim configs, but suck for flags/toggles/options.
* "[String|any old content]" * "[Boolean|true]" * "[Number|1]"
It also allows statically typing and transforming env strings into much more useful and complex structures.
I don't see any problem with 4 different things using it.
The point of it is basic, rather then VARIABLE=WHATEVER you just copy and paste a .env and it picks it up.
But you can also just use regular environment variables if you want.
Because you want to know what type your variables are?
Of course, in this case you do know, they're strings.
I for one am glad that with 2 lines of code I get type safe environment variables with config overrides in go, and never have to think about it ever again.
I feel you on the typing, but the format could accomodate such a tool. Code away! :)
If you don’t want/need to read env vars… why use .env? If you do need to, then you’re stuck treating them as string input, sure, but that’s got nothing to do with .env files. They just help set env vars. If you get rid of your .env file but are still reading from env vars, all you’ve done is tie one hand behind your back.
Is this attitude/phobia a consequence of folks not starting their programmer journey with simple command line programs, anymore?
Try cuelang.org