I have this code used to construct an ElasticSearch json query:
```
type Term = map[string]interface{}
type QueryString = map[string]interface{}
type Range = map[string]interface{}
type Match = map[string]string
type HasTermOrMatch = struct {
Term `json:"term,omitempty"`
QueryString `json:"query_string,omitempty"`
Match `json:"match,omitempty"`
Range `json:"range,omitempty"`
}
var boolField struct {
Must []HasTermOrMatch `json:"must"`
MustNot []HasTermOrMatch `json:"must_not"`
Filter []HasTermOrMatch `json:"filter"`
Should []HasTermOrMatch `json:"should"`
}
```
my question is - how do I omit an array on boolField if the array is empty?
I hear there might be an interface I can add something like this:
func (v Match) IsZero() bool {
return len(v) < 1
}
func (v Term) IsZero() bool {
return len(v) < 1
}
func (v Range) IsZero() bool {
return len(v) < 1
}
func (v QueryString) IsZero() bool {
return len(v) < 1
}
anyone know how to do this?
thanks
-alex
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/b828954e-57ac-4c0d-b816-2edb44b74c63n%40googlegroups.com.