Documentation ¶
Overview ¶
The config package provides a simple application configuration system with strongly-typed objects. Configuration is read from either a YAML or JSON file and returned to the application.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromFile ¶
FromFile reads application configuration from a file found at path, then returns the decoded data to the application-supplied object, konf.
Errors reading the file, decoding the file, or if the file is of an unexpected type are returned.
Example ¶
Reads the AppConfig data from config_example.yaml and prints it.
os.Setenv("PORT", "9000") var c = new(AppConfig) if err := FromFile("config_example.yaml", c); err != nil { fmt.Printf("Error: %v", err) } fmt.Printf("%+v\n", *c)
Output: {Server:{Port:9000} Database:{Driver:postgres Hostname:localhost Port:5432 Username:postgres Password:dummy Name:my_database}}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.