cf_env,
cf_json, cf_default, cf_secret, …) is replaced by one routing tag
cfg and one behavior tag gos. Each source derives its key from the base
name via a naming strategy (env → SCREAMING_SNAKE, files → the name as
written), overridable per source in the cfg tag.cf_priority tag and the global
GOSTRUCTOR_PRIORITY selector are gone. Priority is simply the order of the
sources you pass to WithSources — first source that resolves a field wins.Configure[T](cfg *T, opts ...Option) (*T, error) replaces
ConfigureSmart/ConfigureSetup/ConfigureEasy and their
(interface{}, error) + type-assert calling convention.go get only when you need them.goccy/go-yaml.log/slog via WithLogger; nothing is logged
unless you pass one.Source is a two-method interface (Name, Resolve) any package can
implement and register via WithSources — see gostructor/yaml’s
source.go for a short example.The whole tag family (cf_env, cf_default, cf_json, cf_secret,
cf_priority, …) is replaced by two tags, cfg and gos. Mechanical
mapping:
| Old | New |
|---|---|
cf_env:"DB_PORT" |
cfg:"port,env:DB_PORT" (or just cfg:"port" → PORT) |
cf_json:"server.host" |
cfg:"host,json:server.host" |
cf_ini:"db#pw" |
cfg:"pw,ini:db#pw" |
cf_yaml/cf_toml/cf_hocon/cf_vault:"..." |
cfg:"name,<source>:..." |
cf_default:"8080" |
gos:"default:8080" |
cf_secret:"" |
gos:"secret" |
cf_priority:"..." + GOSTRUCTOR_PRIORITY |
source order in WithSources(...) |
Other changes:
ConfigureSmart(cfg) / myStruct.(*Config) → cfg, err := gostructor.Configure(&Config{}),
no type assertion needed.ConfigureSetup(cfg, prefix, []infra.FuncType{...}) →
gostructor.Configure(&Config{}, gostructor.WithSources(...)).WithSources — they’re no longer bundled into the core import.Source interface method Tag() is now Name(); error fields
SourceError.Tag/NotResolvedError.Tags are now .Source/.Sources
(they name sources, not struct tags).json:server.host); the old implicit struct-name-based prefixing is gone.ChangeLogLevel/ChangeLogFormatter (global logrus config) →
gostructor.WithLogger(*slog.Logger), passed per call.*ConvertError. Configs that relied on 3.9 landing
in an int as 3 will now fail loudly; make the field a float, or round
the value in a WithHook, to keep the old behavior explicitly.