title: How to remove duplicates strings or int from Slice in Go
body: <p>Let's say I have a list of student cities and the size of it could be 100 or 1000, and I want to <strong>filter out all duplicates</strong> cities.</p>
  <p>I want a generic solution that I can use to remove all duplicate strings from any slice.</p>
  <p>I am new to Go Language, So I tried to do it by looping and checking if the element exists using another loop function.</p>
  <p><strong>Students' Cities List (Data):</strong></p>
  <pre><code>studentsCities := []string{&quot;Mumbai&quot;, &quot;Delhi&quot;, &quot;Ahmedabad&quot;, &quot;Mumbai&quot;, &quot;Bangalore&quot;, &quot;Delhi&quot;, &quot;Kolkata&quot;, &quot;Pune&quot;}
  </code></pre>
  <p><strong>Functions that I created, and it's doing the job:</strong></p>
  <pre><code>func contains(s []string, e string) bool {
      for _, a := range s {
          if a == e {
              return true
          }
      }
      return false
  }
  
  func removeDuplicates(strList []string) []string {
      list := []string{}
      for _, item := range strList {
          fmt.Println(item)
          if contains(list, item) == false {
              list = append(list, item)
          }
      }
      return list
  }
  </code></pre>
  <p><strong>My solution test</strong></p>
  <pre><code>func main() {
      studentsCities := []string{&quot;Mumbai&quot;, &quot;Delhi&quot;, &quot;Ahmedabad&quot;, &quot;Mumbai&quot;, &quot;Bangalore&quot;, &quot;Delhi&quot;, &quot;Kolkata&quot;, &quot;Pune&quot;}
  
      uniqueStudentsCities := removeDuplicates(studentsCities)
      
      fmt.Println(uniqueStudentsCities) // Expected output [Mumbai Delhi Ahmedabad Bangalore Kolkata Pune]
  }
  </code></pre>
  <p>I believe that the above solution that I tried is <strong>not an optimum solution</strong>. Therefore, I need help from you guys to <strong>suggest the fastest way to remove duplicates from the slice?</strong></p>
  <p><em>I checked StackOverflow, this question is not being asked yet, so I didn't get any solution.</em></p>