title: Go parse yaml file
body: <p>I'm trying to parse a yaml file with Go. Unfortunately I can't figure out how. The yaml file I have is this:</p>
  
  <pre><code>---
  firewall_network_rules:
    rule1:
      src:       blablabla-host
      dst:       blabla-hostname
  ...
  </code></pre>
  
  <p>I have this Go code, but it does not work:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "io/ioutil"
      "path/filepath"
  
      "gopkg.in/yaml.v2"
  )
  
  type Config struct {
      Firewall_network_rules map[string][]string
  }
  
  func main() {
      filename, _ := filepath.Abs("./fruits.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.Firewall_network_rules)
  }
  </code></pre>
  
  <p>When I run this, I get an error. I think it's because I haven't created a struct for the src and dst key/values. FYI: when I change that to a list, it works.</p>
  
  <p>So above code parses this:</p>
  
  <pre><code>---
  firewall_network_rules:
    rule1:
      - value1
      - value2
  ...
  </code></pre>