title: Array from Yaml - Golang
body: <p>I try to create configuration file for my go app what loops through some jobs.</p>
  
  <p>My .yaml file looks like that (array):</p>
  
  <pre><code>jobToRun:
    - name: This is my first job to run
      sqlToRun: select 1 from some_table
      someVariable: 1
  
    - name: Other job to run
      sqlToRun: select 2 from some_table
      someVariable: 2
  </code></pre>
  
  <p>I have successfully imported the YAML file and created also structure.</p>
  
  <pre><code>
      type Service struct {
          JobToRun []struct {
              Name         string `yaml:"name"`
              SQLToRun     string `yaml:"SqlToRun"`
              SomeVariable int    `yaml:"someVariable"`
          } `yaml:"jobToRun"`
      }
  </code></pre>
  
  <p>But I have no idea how to assign them to variable.</p>
  
  <p>I tried some stuff what work with Json array-s but without any luck.</p>
  
  <p>So I tried to print it to console without any luck:</p>
  
  <pre><code>println(service.JobToRun.name[0])
  </code></pre>
  
  <p>before that I tried to assign that SQL to my variable (which works if it is not an array item.</p>
  
  <pre><code>var sqlQuery = service.JobToRun.name[0] 
  </code></pre>
  
  <p>And here is what I try to accomplish:</p>
  
  <p>I take the Job parameters from .yaml array and run it.<br>
  I am using that kind of array in YAML because it is easiest way to add new jobs.</p>