Go Get Env not finding .env after deployment
triptoafsin
HOBBYOP

a year ago

I've made REST api with GO, I've used gogetenv to load the .env file, but it doesn't find it in the Railway environment and the app crashes

Solved

4 Replies

a year ago

You shouldn't have .env files in production, if you want to load environment variables then you can do so in the service's Variables tab. I don't have experience with Go but you'll need to make gogetenv fail gracefully if it doesn't find a .env file


triptoafsin
HOBBYOP

a year ago

Thanks I solved the issue, it was quite unique how Go handles these scenarios


dev

You shouldn't have .env files in production, if you want to load environment variables then you can do so in the service's Variables tab. I don't have experience with Go but you'll need to make gogetenv fail gracefully if it doesn't find a .env file

triptoafsin
HOBBYOP

a year ago

Thanks I solved the issue, it was quite unique how Go handles these scenarios

I just had to prevent the panic/fail and fallback to system default to make it work


a year ago

Awesome, I'm very glad you got it working smiley emoji


Status changed to Solved dev about 1 year ago


Loading...