Documentation ¶
Overview ¶
Example ¶
Example is a basic example for the usage of the ini source.
package main import ( "fmt" "gitlab.com/stp-team/congo" ) // content is the content of a ini-file used in // this example const content = "" + "# Comment\n" + "; Number\n" + "number=54\n" + "; Decimal\n" + "decimal=0.5\n" + "[section]\n" + "duration=2h45m" // Example is a basic example for the usage of the ini source. func main() { // Get ini source bytes := []byte(content) src := FromBytes(bytes) // main configuration cfg := congo.New("main", src) debug := cfg.Bool("debug", false, "Can be used to enable debug mode.") number := cfg.Int("number", 0, "Set a number") decimal := cfg.Float64("decimal", 0.2, "Set a decimal") // section of configuration subCfg := congo.New("section", src.Section("section")) duration := subCfg.Duration("duration", 0, "Set the duration.") // Load configurations cfg.Init() cfg.Load() subCfg.Init() subCfg.Load() if *debug { fmt.Println("Debug enabled!") } fmt.Printf("Using number %d and decimal %f\n", *number, *decimal) fmt.Printf("%v", *duration) }
Output: Using number 54 and decimal 0.500000 2h45m0s
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Source ¶
type Source interface { congo.Source Section(name string) Source WriteDefaults(w io.Writer) error SetLooseLoad(loose bool) Source }
Source a ini source uses input in ini-syntax to load settings.
func FromFile ¶
FromFile creates a new ini source which uses the file at given path to load the configuration.
func New ¶
func New(reader io.ReadCloser) Source
New creates a new ini source which reads from given reader.
Click to show internal directories.
Click to hide internal directories.