Documentation
¶
Overview ¶
a Go package to interact with arbitrary YAML.
Example:
var data = []byte(`
name: smallfish
age: 99
bool: true
bb:
cc:
dd:
- 111
- 222
- 333
`
y, err := simpleyaml.NewYaml(data)
if err != nil {
// ERROR
}
if v, err := y.Get("name").String(); err == nil {
fmt.Println("value:", v)
}
// y.Get("age").Int()
// y.Get("bool").Bool()
// y.Get("bb").Get("cc").Get("dd").Array()
// y.Get("bb").Get("cc").Get("dd").GetIndex(1).Int()
// y.GetPath("bb", "cc", "ee").String()
Index ¶
- type Yaml
- func (y *Yaml) Array() ([]interface{}, error)
- func (y *Yaml) Bool() (bool, error)
- func (y *Yaml) Get(key string) *Yaml
- func (y *Yaml) GetIndex(index int) *Yaml
- func (y *Yaml) GetPath(branch ...string) *Yaml
- func (y *Yaml) Int() (int, error)
- func (y *Yaml) Map() (map[interface{}]interface{}, error)
- func (y *Yaml) String() (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Yaml ¶
type Yaml struct {
// contains filtered or unexported fields
}
func (*Yaml) Get ¶
Get returns a pointer to a new `Yaml` object for `key` in its `map` representation
Example:
y.Get("xx").Get("yy").Int()
func (*Yaml) GetIndex ¶
GetIndex returns a pointer to a new `Yaml` object. for `index` in its `array` representation
Example:
y.Get("xx").GetIndex(1).String()
func (*Yaml) GetPath ¶
GetPath searches for the item as specified by the branch
Example:
y.GetPath("bb", "cc").Int()
Click to show internal directories.
Click to hide internal directories.