Golang nested Yaml values
<p>I am trying to access Yaml files and grab individual values, but am struggling with the Struct syntax to achieve this.  The code below processes the Yaml and I can print the full Struct, but how can I access the individual <code>ecs.services.name</code> attribute?</p>

<p>Any recommendations on how to handle this is welcome as I have come across several Yaml libraries but haven't been able to get any of them to fully work.</p>

<p><strong>test.yaml:</strong></p>

<pre><code>ecs:
  services:
    - name: my-service
      taskDefinition: my-task-def
      desiredCount: 1
</code></pre>

<p><strong>Yaml.go</strong></p>

<pre><code>package main

import (
    "fmt"
    "io/ioutil"
    "path/filepath"

    "gopkg.in/yaml.v2"
)

type Config struct {
    //Ecs []map[string]string this works for ecs with name
    Ecs struct {
        Services []struct {
            Name           string
            TaskDefinition string
            DesiredCount   int
        }
    }
    //Services []map[string][]string
}

func main() {
    filename, _ := filepath.Abs("test.yaml")

    yamlFile, err := ioutil.ReadFile(filename)
    check(err)

    var config Config

    err = yaml.Unmarshal(yamlFile, &amp;config)
    check(err)

    fmt.Printf("Description: %#v\n", config.Ecs.Services)
}

func check(e error) {
    if e != nil {
        panic(e)
    }
}
</code></pre>

<p><strong>Output</strong></p>

<pre><code>$ go run yaml.go
Description: []struct { Name string; TaskDefinition string; DesiredCount int }{struct { Name string; TaskDefinition string; DesiredCount int }{Name:"my-service", TaskDefinition:"", DesiredCount:0}}
</code></pre>