title: How can I filter an array from a array of arrays where all the items in one array matches some of the items in another array?
body: <h3>TL/DR</h3>
  
  <p>How can I filter an array of arrays in go against an array of strings?</p>
  
  <p>Is there a <code>some</code> or <code>any</code> equivalent of JS/Py in go where I can filter an array of arrays if some or all the items in an array is present in another array? </p>
  
  <p>So for example, consider this as the source array:</p>
  
  <pre class="lang-golang prettyprint-override"><code>arrays := [][]string{
          {"some", "value"},
          {"some", "value", "another"},
          {"value", "another", "test"},
          {"value", "test"},
          {"some", "test"},
      }
  </code></pre>
  
  <p>And I want to filter <code>arrays</code> by <code>[]string{"some", "value"}</code> if all the items here are found in the array. </p>
  
  <p>The expected output is </p>
  
  <pre><code>[[some value] [some value another]]
  </code></pre>
  
  <p>Altervatively, if I change my filter to <code>[]string{"some", "test"}</code>, the expected value is <code>[[some test]]</code></p>
  
  <p>I can get the logic down quite right in my test code</p>
  
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import "fmt"
  
  func inArray(s string, arr []string) bool {
      for _, a := range arr {
          if s == a {
              return true
          }
      }
      return false
  }
  
  func main() {
      arrays := [][]string{
          {"some", "value"},
          {"some", "value", "another"},
          {"value", "another", "test"},
          {"value", "test"},
          {"some", "test"},
      }
      filterBy := []string{"some", "value"}
      hold := make([][]string, 0)
      // Ignore this because it doesnt work as expected
      for _, arr := range arrays {
          for _, f := range filterBy {
              if ok := inArray(f, arr); ok {
                  hold = append(hold, arr)
              }
          }
      }
      fmt.Println(hold)
  }
  </code></pre>