📂Config

Structuring Application Configuration

The config directory is a pivotal point in the Cillop Architecture. Within, you'll find the structures and utilities necessary for reading, interpreting, and serving configuration data to the rest of your application. Its primary role is to encapsulate settings and parameters essential for the app's functioning, usually derived from environment variables or configuration files.

Why Environment Variables?

Environment variables offer a portable way to configure applications. They can be adjusted without altering the codebase, which is especially handy when deploying in various environments like development, staging, and production.

Sample Configuration Struct

project-name/config/config.go
package config

type HttpServer struct {
	Host string `env:"HTTP_SERVER_HOST" envDefault:"localhost"`
	Port int    `env:"HTTP_SERVER_PORT" envDefault:"3000"`
}

type App struct {
   Http HttpServer
}

Last updated