title: Compare a string against a struct field within a slice of structs (sort.Search golang)
body: <pre><code>type user struct {
      name string
      age  int
  }
  data := []user{
      {
          name: &quot;timothy&quot;,
          age:  23,
      },
      {
          name: &quot;johnson&quot;,
          age:  45,
      },
      {
          name: &quot;jason&quot;,
          age:  44,
      },
      {
          name: &quot;handson&quot;,
          age:  15,
      },
      {
          name: &quot;andrew&quot;,
          age:  41,
      },
  }
  fmt.Println(data)
  val := &quot;johnson&quot;
  found := false
  i := sort.Search(len(data), func(i int) bool {
      println(i)
      return data[i].name == val
  })
  if i &lt; len(data) &amp;&amp; data[i].name == val {
      found = true
  }
  fmt.Println(val, found)
  </code></pre>
  <p>I tried to search for a string within an array of structs that including some string fields, but couldn't get a match, for example using johnson or andrew. What is the problem? Thank you!</p>