Skip to content

All matchers ​

The matchers of the match package, by their Go name and their name in mock files, which ignores case. Equalf, StrictEqualf, EqualIgnoreCasef and Containf take their expected value as a format and its arguments. A blank mock-file name means Go only. Each row links to the page that explains it.

GoMock filePage
Equal(v), Eqequal, eqEquality and text
StrictEqual(v), EQSequalstrict, eqsEquality and text
EqualIgnoreCase(s), EQIequalignorecase, eqiEquality and text
IsIn(items)isinEquality and text
EqualBytes(b)equalbytesEquality and text
Contain(v)containsEquality and text
HasPrefix(s), HasSuffix(s)hasprefix, hassuffixEquality and text
GlobMatch(pattern)globEquality and text
RegExpr(expr)regex, regexpEquality and text
Trim(m)trimEquality and text
ToLower(m), ToUpper(m)lowercase, uppercaseEquality and text
Split(sep, m)splitEquality and text
Present()presentEquality and text
Nil()nilEquality and text
Empty()emptyEquality and text
Truthy(), Falsy()truthy, falsyEquality and text
Anything()anythingEquality and text
URLPath(glob), URLPathf, URLPathMatch(m)urlpathEquality and text
RequestURI(uri)requesturiEquality and text
GreaterThan(n), GTgreater, gtNumbers, dates and times
GreaterThanOrEqual(n), GTEgreatereq, gteNumbers, dates and times
LessThan(n)less, ltNumbers, dates and times
LessThanOrEqual(n), LTElesseq, lteNumbers, dates and times
Before(t), BeforeNow()beforeNumbers, dates and times
After(t), AfterNow()afterNumbers, dates and times
EqualDateTime(t), EqualDateTimeNow()equaldatetime, eqdtNumbers, dates and times
Len(n)len, lengthLists and objects
Each(m)eachLists and objects
Some(m)someLists and objects
Item(i, m)itemLists and objects
ItemsMatch(items)itemsmatchLists and objects
ItemsMatch with matchershasexactlyLists and objects
HasKey(path)haskeyLists and objects
JSONPath(path, m), Fieldjsonpath, fieldJSON and XML
JWT(m)jwtJSON and XML
SignedJWT(keys, m)signedjwtJSON and XML
EqualJSON(doc, opts...), EQJequaljson, eqjJSON and XML
JSONSchema(schema, opts...)jsonschemaJSON and XML
EqualXML(doc, opts...), EQXequalxml, eqxJSON and XML
XPath(expr, m, opts...)xpathJSON and XML
All(ms...)allCombining
Any(ms...)anyCombining
Both(a, b), Either(a, b), XOR(a, b)both, either, xorCombining
Not(m)notCombining
Function(fn), Predicate(fn)Combining
Peek(m, action)Combining