title: Finding Unique Items in a Go Slice or Array
body: <p>I'm pretty new to go and I'm really, really confused right now. </p>
  
  <p>Let's say I have a list of coordinates and lets say I have some doubles in this list of coordinates. I can't for the life of me figure out how to make a unique list. Normally in Python I can "cheat" with sets and other built-ins. Not so much in Go.</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "reflect"
  )
  
  type visit struct {
      x, y int
  }
  
  func main() {
      var visited []visit
      var unique []visit
  
      visited = append(visited, visit{1, 100})
      visited = append(visited, visit{2, 2})
      visited = append(visited, visit{1, 100})
      visited = append(visited, visit{1, 1})
  
      unique = append(unique, visit{1, 1})
  
      fmt.Println(unique)
  
      // Go through the visits and find the unique elements
      for _, v := range visited {
          for _, u := range unique {
  
              fmt.Printf("Here's unique: %v\n", unique)
              fmt.Printf("Comparing %v to %v is %v\n", v, u, reflect.DeepEqual(v, u))
  
              if reflect.DeepEqual(v, u) {
                  fmt.Println("Skip")
              } else {
                  unique = append(unique, v)
              }
          }
      }
  
      fmt.Println(unique)
  }
  </code></pre>
  
  <p><kbd><a href="https://play.golang.org/p/7lYjfSaBP0" rel="nofollow">Run it on Playground</a></kbd></p>