Posted on Leave a comment

Building Scalable Web Services in Golang

gophers learning

 

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.

Source: Building Scalable Web Services in Golang – Myntra Engineering – Medium

The above post has some very good points about building web services in Go. Here is one of mine.

Configuration

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:

viper.SetEnvPrefix("APP") 
viper.AutomaticEnv()

That code can be placed in the init() or main() function and then anywhere in your app, you can run

id := Get("id") // will get APP_ID
Spread the love
Posted on Leave a comment

There are no comments

Leave a comment... please :-)

Your email address will not be published. Required fields are marked *