Documentation ¶
Overview ¶
Cross-platform configuration manager
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Base string Entries map[string]ConfigEntry }
func NewConfig ¶
Create a new Config manager
Example ¶
package main import ( "fmt" "github.com/ddollar/config" ) func main() { conf := config.NewConfig("myapp") fmt.Println(conf.Base) }
Output: myapp
func (*Config) Delete ¶
Delete a config key/value pair
Example ¶
package main import ( "fmt" "github.com/ddollar/config" ) func main() { conf := config.NewConfig("myapp") conf.Save("logins", "user@example.org", "12345") conf.Save("logins", "user2@example.org", "12345") conf.Delete("logins", "user2@example.org") logins, _ := conf.List("logins") fmt.Println(logins) }
Output: [user@example.org]
func (*Config) List ¶
List keys for a given config
Example ¶
package main import ( "fmt" "github.com/ddollar/config" ) func main() { conf := config.NewConfig("myapp") conf.Save("logins", "user@example.org", "12345") conf.Save("logins", "user2@example.org", "12345") logins, _ := conf.List("logins") fmt.Println(logins) }
Output: [user2@example.org user@example.org]
func (*Config) Load ¶
Load a value for a config key
Example ¶
package main import ( "fmt" "github.com/ddollar/config" ) func main() { conf := config.NewConfig("myapp") conf.Save("logins", "user@example.org", "12345") password, _ := conf.Load("logins", "user@example.org") fmt.Println(password) }
Output: 12345
func (*Config) Save ¶
Save a key/value pair for a config
Example ¶
package main import ( "fmt" "github.com/ddollar/config" ) func main() { conf := config.NewConfig("myapp") conf.Save("logins", "user@example.org", "12345") password, _ := conf.Load("logins", "user@example.org") fmt.Println(password) }
Output: 12345
type ConfigEntry ¶
Click to show internal directories.
Click to hide internal directories.