One of the very intrinsic aspects of the language is its insistence on doing things the “right” way. From the way golang projects are structured to the strictness in linting and documentation, every single aspect of Golang, done right, is delightfully intuitive and ergonomic.
The above post has some very good points about building web services in Go. Here is one of mine.
Whenever possible, use environmental variables for configuration rather than .env files. Take a look at the viper package to help with this.
With Viper, you can simply add your prefix and then call the needed variables when needed. Here is what that’ll look like:
That code can be placed in the
main() function and then anywhere in your app, you can run
id := Get("id") // will get APP_ID