title: How to search for an element in a golang slice
body: <p>I have a slice of structs.</p>
  
  <pre><code>type Config struct {
      Key string
      Value string
  }
  
  // I form a slice of the above struct
  var myconfig []Config 
  
  // unmarshal a response body into the above slice
  if err := json.Unmarshal(respbody, &amp;myconfig); err != nil {
      panic(err)
  }
  
  fmt.Println(config)
  </code></pre>
  
  <p>Here is the output of this:</p>
  
  <pre><code>[{key1 test} {web/key1 test2}]
  </code></pre>
  
  <p>How can I search this array to get the element where <code>key="key1"</code>?</p>