flexyaml

package module
v0.0.0-...-f458bfa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2017 License: MIT Imports: 3 Imported by: 6

README

flexyaml

CircleCI GoDoc

Flexible yaml is based on http://gopkg.in/yaml.v2 and supports case insensitive keys (!= RFC)

Used in https://github.com/moul/advanced-ssh-config

Example

package main

import (
    "fmt"
    "log"

    "github.com/moul/flexyaml"
)

// An example showing how to unmarshal embedded
// structs from YAML.

type StructA struct {
    A string `yaml:"a"`
}

type StructB struct {
    // Embedded structs are not treated as embedded in YAML by default. To do that,
    // add the ",inline" annotation below
    StructA `yaml:",inline"`
    B       string `yaml:"b"`
}

var data = `
a: a string from struct A
B: a string from struct B
`

func main() {
    var b StructB

    err := flexyaml.Unmarshal([]byte(data), &b)
    if err != nil {
        log.Fatal("cannot unmarshal data: %v", err)
    }
    fmt.Println(b.A)
    fmt.Println(b.B)
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeFlexible

func MakeFlexible(in []byte) ([]byte, error)

func Unmarshal

func Unmarshal(in []byte, out interface{}) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL