Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set different configs for prod an local environments in GoFr?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading