title: How to group multiple yaml fields into one
body: <p>This is the data I have:</p>
  
  <pre><code>[alpha:0.1, beta:0.2] //1
  [alpha:0.3, beta:0.4] //2
  </code></pre>
  
  <p>I am designing YAML for the data. </p>
  
  <p>Note that </p>
  
  <ol>
  <li><code>alpha</code> and <code>beta</code> could be changed. </li>
  <li>The length of <code>[alpha:0.1, beta:0.2]</code> can be increased and decreased. I want to group <code>alpha</code> and <code>beta</code> together. </li>
  </ol>
  
  <p>I have read a few basic tutorial, but I do not know how to group <code>alpha</code> and <code>beta</code> together.</p>
  
  <p>Here is my attempt:</p>
  
  <pre><code>params: 
    - 
      paramKey: alpha
      paramVal: 0.1
    - 
      paramKey: beta
      paramVal: 0.2
    - 
      paramKey: alpha
      paramVal: 0.3
    - 
      paramKey: beta
      paramVal: 0.4
  </code></pre>
  
  <p>Update: </p>
  
  <p>I used the following:</p>
  
  <pre><code>params: 
    - alpha: 0.1
      beta: 0.2
    - alpha: 0.3
      beta: 0.4
  </code></pre>
  
  <p>Code: </p>
  
  <pre><code>func main() {
      f, err := os.OpenFile("", os.O_RDWR|os.O_CREATE, 0666)
      if err != nil {
          log.Panic(err)
      }
  
      fByte, err := ioutil.ReadAll(f)
      if err != nil {
          log.Panic(err)
      }
  
      var m params
      err = yaml.Unmarshal(fByte, &amp;m)
      if err != nil {
          log.Fatalf("error: %v", err)
      }
      fmt.Printf("%v \n", m)
  }
  
  type params struct {
      params []map[string]float32 `yaml:"params"`
  }
  </code></pre>
  
  <p>The output is <code>{[]}</code>.</p>