Operators matrices
Operator → go type matrix
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
All |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | All |
Any |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Any |
Array |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ptr on array | ✓ | ✗ | ✗ | Array |
ArrayEach |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | ArrayEach |
Bag |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | Bag |
Between |
✗ | ✗ | ✓ | ✓ | ✓ | todo | ✗ | ✗ | ✗ | time.Time |
✗ | ✓ | ✗ | ✗ | Between |
Cap |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | Cap |
Catch |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Catch |
Code |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Code |
Contains |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ + fmt.Stringer /error |
✗ | ✗ | Contains |
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ContainsKey |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | ContainsKey |
Delay |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Delay |
Empty |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ | ptr on array/slice/map/string | ✓ | ✓ | ✗ | Empty |
ErrorIs |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | error |
✗ | ✗ | ErrorIs |
First |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | First |
Grep |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | Grep |
Gt |
✗ | ✗ | ✓ | ✓ | ✓ | todo | ✗ | ✗ | ✗ | time.Time |
✗ | ✓ | ✗ | ✗ | Gt |
Gte |
✗ | ✗ | ✓ | ✓ | ✓ | todo | ✗ | ✗ | ✗ | time.Time |
✗ | ✓ | ✗ | ✗ | Gte |
HasPrefix |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | []byte |
✗ | ✗ | ✗ | ✓ + fmt.Stringer /error |
✗ | ✗ | HasPrefix |
HasSuffix |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | []byte |
✗ | ✗ | ✗ | ✓ + fmt.Stringer /error |
✗ | ✗ | HasSuffix |
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Ignore |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Ignore |
Isa |
✗ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Isa |
JSON |
✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | JSON |
JSONPointer |
✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | JSONPointer |
Keys |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | Keys |
Last |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | Last |
Lax |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Lax |
Len |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ | Len |
Lt |
✗ | ✗ | ✓ | ✓ | ✓ | todo | ✗ | ✗ | ✗ | time.Time |
✗ | ✓ | ✗ | ✗ | Lt |
Lte |
✗ | ✗ | ✓ | ✓ | ✓ | todo | ✗ | ✗ | ✗ | time.Time |
✗ | ✓ | ✗ | ✗ | Lte |
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Map |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ptr on map | ✓ | ✗ | ✗ | Map |
MapEach |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ptr on map | ✓ | ✗ | ✗ | MapEach |
N |
✗ | ✗ | ✗ | ✓ | ✓ | todo | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | N |
NaN |
✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | NaN |
Nil |
✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✓ | ✓ | ✓ | ✓ | Nil |
None |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | None |
Not |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Not |
NotAny |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | NotAny |
NotEmpty |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ | ptr on array/slice/map/string | ✓ | ✓ | ✗ | NotEmpty |
NotNaN |
✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | NotNaN |
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NotNil |
✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✓ | ✓ | ✓ | ✓ | NotNil |
NotZero |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | NotZero |
PPtr |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | PPtr |
Ptr |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | Ptr |
Re |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | []byte |
✗ | ✗ | ✗ | ✓ + fmt.Stringer /error |
✗ | ✗ | Re |
ReAll |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | []byte |
✗ | ✗ | ✗ | ✓ + fmt.Stringer /error |
✗ | ✗ | ReAll |
Recv |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ptr on chan | ✓ | ✓ | ✗ | Recv |
Set |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | Set |
Shallow |
✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✓ | ✓ | ✓ | ✓ | Shallow |
Slice |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ptr on slice | ✓ | ✗ | ✗ | Slice |
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Smuggle |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Smuggle |
SStruct |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ptr on struct | ✓ | ✗ | ✗ | SStruct |
String |
✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | []byte |
✗ | ✗ | ✗ | ✓ + fmt.Stringer /error |
✗ | ✗ | String |
Struct |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ptr on struct | ✓ | ✗ | ✗ | Struct |
SubBagOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | SubBagOf |
SubJSONOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ptr on map/struct | ✓ | ✗ | ✗ | SubJSONOf |
SubMapOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ptr on map | ✓ | ✗ | ✗ | SubMapOf |
SubSetOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | SubSetOf |
SuperBagOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | SuperBagOf |
SuperJSONOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ptr on map/struct | ✓ | ✗ | ✗ | SuperJSONOf |
Operator vs go type | nil | bool | string | {u,}int* | float* | complex* | array | slice | map | struct | pointer | interface¹ | chan | func | operator |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SuperMapOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ptr on map | ✓ | ✗ | ✗ | SuperMapOf |
SuperSetOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | SuperSetOf |
SuperSliceOf |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ | ptr on array/slice | ✓ | ✗ | ✗ | SuperSliceOf |
Tag |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Tag |
TruncTime |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | time.Time |
todo | ✓ | ✗ | ✗ | TruncTime |
Values |
✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | Values |
Zero |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Zero |
Legend:
- ✗ means using this operator with a value type of this kind will always fail
- ✓ means using this operator with a value type of this kind can succeed
[]byte
,time.Time
, ptr on X,fmt.Stringer
,error
means using this operator with this go type can succeed- todo means should be implemented in future (PRs welcome :) )
- ¹ + ✓ means using this operator with the data behind the interface can succeed
go type → operator matrix
Operators likely to succeed for each go type:
Untyped nil
value
All
Any
Catch
Code
Delay
Ignore
JSON
JSONPointer
Lax
Nil
None
Not
NotNil
NotZero
Shallow
Smuggle
Tag
Zero
bool
values (or any type based on bool
)
string
values (or any type based on string
)
All
Any
Between
Catch
Code
Contains
Delay
Empty
Gt
Gte
HasPrefix
HasSuffix
Ignore
Isa
JSON
JSONPointer
Lax
Lt
Lte
None
Not
NotEmpty
NotZero
Re
ReAll
Shallow
Smuggle
String
Tag
Zero
Integer values (uint*
, int*
or any type based on them)
All
Any
Between
Catch
Code
Delay
Gt
Gte
Ignore
Isa
JSON
JSONPointer
Lax
Lt
Lte
N
None
Not
NotZero
Smuggle
Tag
Zero
Float values (float32
, float64
or any type based on them)
All
Any
Between
Catch
Code
Delay
Gt
Gte
Ignore
Isa
JSON
JSONPointer
Lax
Lt
Lte
N
NaN
None
Not
NotNaN
NotZero
Smuggle
Tag
Zero
Complex values (complex64
, complex128
or any type based on them)
Arrays
All
Any
Array
ArrayEach
Bag
Cap
Catch
Code
Contains
Delay
Empty
First
Grep
Ignore
Isa
JSON
JSONPointer
Last
Lax
Len
None
Not
NotAny
NotEmpty
NotZero
Set
Smuggle
SubBagOf
SubSetOf
SuperBagOf
SuperSetOf
SuperSliceOf
Tag
Zero
Slices
All
Any
ArrayEach
Bag
Cap
Catch
Code
Contains
Delay
Empty
First
Grep
HasPrefix
only[]byte
HasSuffix
only[]byte
Ignore
Isa
JSON
JSONPointer
Last
Lax
Len
Nil
None
Not
NotAny
NotEmpty
NotNil
NotZero
Re
only[]byte
ReAll
only[]byte
Set
Shallow
Slice
Smuggle
String
only[]byte
SubBagOf
SubSetOf
SuperBagOf
SuperSetOf
SuperSliceOf
Tag
Zero
Maps
All
Any
Catch
Code
Contains
ContainsKey
Delay
Empty
Ignore
Isa
JSON
JSONPointer
Keys
Lax
Len
Map
MapEach
Nil
None
Not
NotEmpty
NotNil
NotZero
Shallow
Smuggle
SubJSONOf
SubMapOf
SuperJSONOf
SuperMapOf
Tag
Values
Zero
Structs
All
Any
Between
onlytime.Time
Catch
Code
Delay
Gt
onlytime.Time
Gte
onlytime.Time
Ignore
Isa
JSON
JSONPointer
Lax
Lt
onlytime.Time
Lte
onlytime.Time
None
Not
NotZero
SStruct
Smuggle
Struct
SubJSONOf
SuperJSONOf
Tag
TruncTime
onlytime.Time
Zero
Interface values
As all operators accept interface values, only specific interfaces are listed below:
Contains
→fmt.Stringer
/error
ErrorIs
HasPrefix
→fmt.Stringer
/error
HasSuffix
→fmt.Stringer
/error
Re
→fmt.Stringer
/error
ReAll
→fmt.Stringer
/error
String
→fmt.Stringer
/error
Any pointer
All
Any
Array
only ptr on arrayArrayEach
only ptr on array/sliceBag
only ptr on array/sliceCatch
Code
Delay
Empty
only ptr on array/slice/map/stringFirst
only ptr on array/sliceGrep
only ptr on array/sliceIgnore
Isa
JSON
JSONPointer
Last
only ptr on array/sliceLax
Map
only ptr on mapMapEach
only ptr on mapNil
None
Not
NotAny
only ptr on array/sliceNotEmpty
only ptr on array/slice/map/stringNotNil
NotZero
PPtr
Ptr
Recv
only ptr on chanSStruct
only ptr on structSet
only ptr on array/sliceShallow
Slice
only ptr on sliceSmuggle
Struct
only ptr on structSubBagOf
only ptr on array/sliceSubJSONOf
only ptr on map/structSubMapOf
only ptr on mapSubSetOf
only ptr on array/sliceSuperBagOf
only ptr on array/sliceSuperJSONOf
only ptr on map/structSuperMapOf
only ptr on mapSuperSetOf
only ptr on array/sliceSuperSliceOf
only ptr on array/sliceTag
Zero
Channels
All
Any
Cap
Catch
Code
Delay
Empty
Ignore
Isa
Lax
Len
Nil
None
Not
NotEmpty
NotNil
NotZero
Recv
Shallow
Smuggle
Tag
Zero