Introducing gorealconf – Type-Safe Dynamic Configuration for Go πŸš€

Hi Gophers! :wave:

I’m excited to share gorealconf, a library designed to make dynamic configuration management simple and efficient for Go applications.

With gorealconf, you can:

  • Dynamically update configurations without restarting your app.
  • Use type-safe APIs (leveraging Go generics) to avoid runtime errors.
  • Combine multiple configuration sources like Redis, etcd, files, and more.
  • Gradually roll out configuration changes with built-in validation and rollback mechanisms.

:file_folder: Examples: Explore Examples
:link: GitHub: gorealconf on GitHub

Here’s a quick example:

type AppConfig struct {
    ServerPort int           `json:"server_port"`
    Timeout    time.Duration `json:"timeout"`
}

cfg := gorealconf.New[AppConfig](
    gorealconf.WithValidation[AppConfig](func(old, new AppConfig) error {
        if new.ServerPort < 1024 {
            return errors.New("port must be >= 1024")
        }
        return nil
    }),
)

// Watch for config changes
changes, _ := cfg.Watch(context.Background())
go func() {
    for newCfg := range changes {
        log.Printf("Config updated: %+v", newCfg)
    }
}()

I’d love to hear your feedback or answer any questions you have! Contributions and ideas for future features are always welcome.

Cheers,
Samuel