title: Golang YAML reading with map of maps
body: <p>Here is my YAML file.</p>
  
  <pre><code>description: fruits are delicious
  fruits:
    apple:
      - red
      - sweet
    lemon:
      - yellow
      - sour
  </code></pre>
  
  <p>I can read a flatter version of this with the <code>gopkg.in/yaml.v1</code> package but I'm stuck trying to figure out how to read this YAML file when it's got what seems like a map of maps.</p>
  
  <pre><code>package main
  
  import (
    "fmt"
    "gopkg.in/yaml.v1"
    "io/ioutil"
    "path/filepath"
  )
  
  type Config struct {
    Description string
    Fruits []Fruit
  }
  
  type Fruit struct {
    Name string
    Properties []string
  }
  
  func main() {
    filename, _ := filepath.Abs("./file.yml")
    yamlFile, err := ioutil.ReadFile(filename)
  
    if err != nil {
      panic(err)
    }
  
    var config Config
  
    err = yaml.Unmarshal(yamlFile, &amp;config)
    if err != nil {
      panic(err)
    }
  
    fmt.Printf("Value: %#v\n", config.Description)
    fmt.Printf("Value: %#v\n", config.Fruits)
  }
  </code></pre>
  
  <p>It can't get the nested Fruits out.  It seems to come back empty.  <code>Value: []main.Fruit(nil)</code>.</p>