title: How to filter slice of struct using filter parameter in GO
body: <p>I am new to GOlang, I trying to filter slice of struct in GO using struct which contain some parameter for filter it. I am trying to do below things but its not work for me. In that code I have filter function which take slice of struct i.e GRN which need to filter using FilterParameter struct.</p>
  <p>My Struct which need to filer</p>
  <pre><code>type GRN struct {
          DocType          string    `json:&quot;docType&quot;`
          GRNNO            string    `json:&quot;GRNNO&quot;`
          PRID             string    `json:&quot;PRID&quot;`
          PRODUCE          string    `json:&quot;PRODUCE&quot;`
          VARIETY          string    `json:&quot;VARIETY&quot;`
  }
  
  
  manyGRNUsers := []GRN{{&quot;GRNAsset&quot;,&quot;GRN0000109&quot;,&quot;PRFAINAPKR0086&quot;,&quot;Sweetcorn&quot;,&quot;CP2&quot;},
      {&quot;GRNAsset&quot;,&quot;GRN0000110&quot;,&quot;PRFAINAPKR0087&quot;,&quot;Sweetcorn&quot;,&quot;CP1&quot;,},
      {&quot;GRNAsset&quot;,&quot;GRN0000112&quot;,&quot;PRFAINAPKR0087&quot;, &quot;Sweetcorn&quot;,&quot;CP2&quot;,},
      {&quot;GRNAsset&quot;,&quot;GRN0000113&quot;,&quot;PRFAINAPKR0089&quot;,&quot;Apple&quot;,&quot;Gala&quot;,}}
  </code></pre>
  <p>Struct which will used for filter parameter.here one thing the field in FilterParameter is dyanamic as above GRN struct value. it could me more then two field but less than or equal to GRN struct field</p>
  <pre><code>  type FilterParameter struct {
          PRODUCE            string    `json:&quot;PRODUCE&quot;`
          VARIETY          string    `json:&quot;VARIETY&quot;`
      
      }
  
  manyFilterParameter := []FilterParameter{{&quot;Sweetcorn&quot;,&quot;CP2&quot; }
  </code></pre>
  <p>I tried below function but its not work for me as I can do only with one field from FilterParameter i.e PRODUCE only and its not dynamic</p>
  <pre><code>   func filter(fu []GRN, su []FilterParameter) (out []GRN) {
          f := make(map[string]struct{}, len(su))
          for _, u := range su {
              f[u.PRODUCE] = struct{}{}
          }
          for _, u := range fu {
              if _, ok := f[u.PRODUCE]; ok {
                  out = append(out, u)
              }
          }
          return
      }
  </code></pre>