So, for my own projects in Go lang, I created a simple library for loading configuration files, so it can load configuration either from .toml files, or from .env files or just from an environment variables.

Then you define your config like that:

  type ServerConfig struct {
    Address  string `env:"HTTP_ADDRESS"`
    Port     int    `env:"HTTP_PORT"`
    UseTLS   bool   `env:"HTTP_USE_TLS"`
    CertFile string `env:"HTTP_CERT_FILE"`
    KeyFile  string `env:"HTTP_KEY_FILE"`

    Timeout int `env:"HTTP_TIMEOUT"`
  }

  type Config struct {
    Server ServerConfig `env:"SERVER"`
  }

So, for example, with the code like this:

  if err := config.LoadToml(&cfg, tomlFileName); err != nil   {
   return nil, err
  }

  if err := config.LoadOverrides(&cfg); err != nil {
   return nil, err  
  }
It can load from TOML file, and from environment variables. This means - service can be either started from container, or run locally with .toml file.