Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 723 Bytes

getting-started.md

File metadata and controls

43 lines (33 loc) · 723 Bytes

docs/getting-started.md

Getting Started with gorealconf

Installation

go get github.com/samuelarogbonlo/gorealconf

Basic Usage

  1. Define your configuration type:
type AppConfig struct {
    ServerPort int           `json:"server_port"`
    Timeout    time.Duration `json:"timeout"`
}
  1. Create a configuration instance:
cfg := gorealconf.New[AppConfig](
    gorealconf.WithValidation[AppConfig](validateConfig),
    gorealconf.WithRollback[AppConfig](true),
)
  1. Watch for changes:
changes, err := cfg.Watch(context.Background())
if err != nil {
    log.Fatal(err)
}

go func() {
    for newCfg := range changes {
        // Handle configuration updates
    }
}()