Go - How to properly use DEV and PROD environments?
Hey, is anyone in here a Go professional and could clear up one or two things for me?
1. How to properly set up and differentiate between environments?
All I was able to find on my own were functions like:
But that's in code, so that would be pushed to my repository and expose my Turso Database Auth Key for example.
Then I researched and found the .env package for Go. So I could use that with command line parameters to decide what env (dev or prod) I would want to use for my app.
Unfortunately that does not work as good with my Tests. I am not sure how to properly check for the environment I am currently in in my tests, as I do not want to test my remote db functionality while developing locally.
2. So how would I avoid running specific tests based on my environment I am currently in?
Would using the
func init()
coupled with flags work for that scenario?
EDIT: I basically solved my issue by using the flags package but I'd still appreciate a professionals opinion on the matter0 Replies