I work on a mac under the macos (ventura) and I also have a windows VM that I run under parallels. I use VS code to develop the code of the project. Mainly, I work under macos but the final app will run on windows, so I was thinking of developing more often in the Windows VM. The code is shared between macos & the windows vm - it's in the same folder.
The question that I have is: the application reads some settings from a .env file, such as a database url. The database url is different on windows than the one on macos. What options do I have in order to be able to run the same code on windows and macos? I was thinking of some options:
- Use a different .env file on windows than on macos, but how to I tell the executable which .env file to use?
- Use the same .env file but annotate the settings with a prefix or suffix, something like:
database_url.macos =postgres:.... , database_url.windows=postgres. Is this achievable at all?
- Distinguish at runtime the OS and use the appropriate setting from the .env file.
I like #2 best. Other options?