title: How do I iterate over an array of a custom type in Go?
body: <p>I have a customer type I have created in my code. I have a function that is reading in a csv file and creating an array from each line. </p>
  
  <pre><code>type DesiredService struct {
      Name string `json:"Name"`
      Status string `json:"Status"`
  }
  </code></pre>
  
  <p>If I print out the variable I have something that looks like
  <code>[{app1 active}{app2 active}]</code></p>
  
  <p>I can not figure out how I would take that variable and iterate over each index. I need to take all of the entries with a Status of active and call another function to check the name against an API. I am thinking maybe I did not set the struct up correctly. </p>
  
  <p>When I check the variable type it returns <code>[]main.DesiredService</code></p>
  
  <p>After reading some of the docs this is what I came up with that is not working. </p>
  
  <pre><code>func checkPagerDutyforService (serviceList []DesiredService) (bool){
      var serviceExist bool()
      for i, v := range serviceList {
          if v == "active" {
              checkIfServiceExist(i, serviceList)
              serviceExist = true
          } else {
              if v != "active"{
                  serviceExist = false
              }
          }
      }
      return serviceExist
  </code></pre>