go/config_example_test.go
Snider 5be20af4b0 feat: eliminate fmt, string concat — add core.Println, use Concat/Path everywhere
New primitive: core.Println() wraps fmt.Println.

Replaced across all test + example files:
- fmt.Println → Println (17 example files)
- fmt.Sprintf → Concat + Sprint
- dir + "/file" → Path(dir, "file") (path security)
- "str" + var → Concat("str", var) (AX consistency)

"fmt" import is now zero across all test files.
String concat with + is zero across all test files.

Remaining 9 stdlib imports (all Go infrastructure):
testing, context, time, sync, embed, io/fs, bytes, gzip, base64

558 tests, 84.5% coverage.

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

41 lines
708 B
Go

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