Documentation ¶
Overview ¶
Package off a Go implementation of off. A lightweight format for small configuration files. See http://bindh3x.io/off.
package main import ( "fmt" "os" off "github.com/umahmood/go-off" ) func main() { file, err := os.Open("test.off") if err != nil { // handle error } defer file.Close() config, err := off.LoadConfig(file) if err != nil { // handle error } if val, err := config.String("banner"); err == nil { fmt.Println("banner:", val) } if val, err := config.Bool("run_as_root"); err == nil { fmt.Println("run_as_root:", val) } if val, err := config.Int("port"); err == nil { fmt.Println("port", val) } a, err := config.Array("my_array") if err != nil { // handle error } x := a[0].(int) fmt.Println("element at index 0", x) y := a[3].(string) fmt.Println("element at index 3", y) z := a[6].(string) fmt.Println("element at index 6", z) }
Index ¶
- type Config
- func (c *Config) Array(key string) ([]interface{}, error)
- func (c *Config) ArrayCount() int
- func (c *Config) Bool(key string) (bool, error)
- func (c *Config) BoolCount() int
- func (c *Config) Int(key string) (int, error)
- func (c *Config) IntCount() int
- func (c *Config) String(key string) (string, error)
- func (c *Config) StringCount() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents a single off configuration instance
func LoadConfig ¶
LoadConfig opens and reads in, an off configuration file
func (*Config) ArrayCount ¶
ArrayCount returns the number of offArray key/value pairs in the configuration
func (*Config) BoolCount ¶
BoolCount returns the number of boolean key/value pairs in the configuration
func (*Config) IntCount ¶
IntCount returns the number of integer key/value pairs in the configuration
func (*Config) StringCount ¶
StringCount returns the number of string key/value pairs in the configuration
Click to show internal directories.
Click to hide internal directories.