Skip to content

goforge gen:config ​

Scaffolds a new Viper configuration file in core/config/ and wires it into core/config/config.go.

Syntax ​

bash
goforge gen:config [name]

Files Created & Modified ​

  1. Creates core/config/<name>.go containing <TypeName>Config and load<TypeName>Config().
  2. Patches core/config/config.go:
    • Adds <TypeName> <TypeName>Config to type AllConfig struct
    • Calls load<TypeName>Config() inside Load()
    • Assigns <TypeName> = cfg.<TypeName>

Manual var (...) Line Required

goforge gen:config currently does not insert <TypeName> <TypeName>Config into the package-level var (...) block in core/config/config.go. Add that single line to var (...) after running gen:config:

go
var (
	App     AppConfig
	DB      DBConfig
	GRPC    GRPCConfig
	HTTP    HTTPConfig
	Encrypt EncryptConfig
	Log     LogConfig
	Redis   RedisConfig // <-- add your generated config type here
)

Released under the Apache-2.0 License.