I have developed an application on GoFr. It uses MySQL. On my local system, the MySQL host url is localhost. But it has different MySQL host url on prod server. Every time, when I make some change in the code, I have to change the MySQL configs in .env file before deploying the application to prod server.
Is there any way to have two different config and GoFr automatically reads the local configs when I am running the application (for testing) on local system and read prod configs when it is running on prod server so that I don’t have to take care of changing the configs before deploying?
>Solution :
you can create more env files with the name
.<environment>.env such as .test.env or .prod.env.
And set GOFR_ENV=test or prod in your system env and it will read from respective environment.
You can also do the following in your terminal, it will set for that particular time when you run your application
GOFR_ENV=test go run main.go