go/config_example_test.go
Snider e65cbde97e feat: complete per-file examples — 54 examples across 17 files
New example files: entitlement, task, lock, log, drive, config,
command, info. Every major source file now has a dedicated
*_example_test.go with compilable, tested examples.

561 tests, 84.8% coverage.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:39:36 +00:00

42 lines
739 B
Go

package core_test
import (
"fmt"
. "dappco.re/go/core"
)
func ExampleConfig_Set() {
c := New()
c.Config().Set("database.host", "localhost")
c.Config().Set("database.port", 5432)
fmt.Println(c.Config().String("database.host"))
fmt.Println(c.Config().Int("database.port"))
// Output:
// localhost
// 5432
}
func ExampleConfig_Enable() {
c := New()
c.Config().Enable("dark-mode")
c.Config().Enable("beta-features")
fmt.Println(c.Config().Enabled("dark-mode"))
fmt.Println(c.Config().EnabledFeatures())
// Output:
// true
// [dark-mode beta-features]
}
func ExampleConfigVar() {
v := NewConfigVar(42)
fmt.Println(v.Get(), v.IsSet())
v.Unset()
fmt.Println(v.Get(), v.IsSet())
// Output:
// 42 true
// 0 false
}