Configuration

Night mode

Configuration

A$AP Scalable Web Services with Go & Docker 🚀 Course

Engineers From These Top Companies and Universities Trust EXLskills

1M+ Professionals | 100+ Institutions

This is the EXLskills free and open-source A$AP Scalable Web Services with Go & Docker Course! It's a highly-accelerated open course that's best-suited for people with a bit of background in software engineering to quickly pick up Go, learn the essential best practices, and hit the ground running!
After this course, you'll be able to build lightweight, scalable, and idiomatic web services that connect to relational (SQL) databases, consider auth, and serve performant JSON REST APIs.
For further practice, we recommend checking out our Go Guided Projects that will give you access to a professional Go developer, detailed documentation, and real-world tasks that you can work on to go from the basics of Go, into building production apps.

Is this course FREE?

Yes, this a 100% free course that you can contribute to on GitHub here!

Have more questions?

Scaffold Project

Configuration

Essential & Non-trivial: Config!

One of the most confusing aspects of building web services, especially those that are automatically deployed into a container orchestration platform (like Kubernetes or AWS' ECS) via Docker, is configuration!

For this purpose, we will use environment variables exclusively, as this is the industry standard! When it comes to managing files (or larger configuration values) you might be able to get away with Base64-encoding them into environment variables and then decoding them as part of your configuration init process, and that can work well with things like key files since they are relatively small, however, larger config files likely must be managed by your orchestration platform and that's out of the scope of this course.

Env Vars in Go

You can always get an env var with os.GetEnv("VAR_NAME") in Go, however, for managing an entire config struct with defaults, we will use a library called 'envconfig' available here.

Logging

We'll cover logging more later, however, you will notice that we'll use the logrus 3rd party logger for sending structured logs to our stdout