📖 3 min read (~ 500 words).

Quick API index

Domains

All assertions are classified into 20 domains to help navigate the API, depending on your use case.

API metrics

Counts for core functionality, and generated variants (formatted, forward, forward-formatted).

Counted for a go1.27 build. Generic assertions gain their forward and forward-formatted variants (the methods of the Assertions type) from go1.27 on, the first release that accepts type parameters on methods; on go1.26 those two variants per generic assertion are excluded by their //go:build guard.

KindCountNote
All core functions145Maintained core (internal)
All core assertions140Usage with *testing.T (per package)
Generic assertions55Type-safe assertions (“T” suffix) (per package)
Helpers (not assertions)5General-purpose utilities, not assertions (per package)
Others0
assert/require variants560Generated variants
Total assertions variants1120Available assertions API
Constructors2Builders of Assertion values
Total API surface1132All variants, constructors and helpers over all packages

Quick index

Table of core assertions, excluding variants. Each function is side by side with its logical opposite (when available).

AssertionOppositeDomainKind
BlockedNotBlockedcondition
BlockedT[E any, CHAN ~chan E] NotBlockedTcondition
CallerInfocommonhelper
Conditioncondition
Consistently[C Conditioner] async
ContainsNotContainscollection
DirExistsDirNotExistsfile
ElementsMatchNotElementsMatchcollection
ElementsMatchT[E comparable] NotElementsMatchTcollection
EmptyNotEmptyequality
EqualNotEqualequality
EqualErrorerror
EqualExportedValuesequality
EqualT[V comparable] NotEqualTequality
EqualValuesNotEqualValuesequality
ErrorNoErrorerror
ErrorAsNotErrorAserror
ErrorAsType[E error] NotErrorAsTypeerror
ErrorContainsErrorNotContainserror
ErrorIsNotErrorIserror
EventuallyWith[C CollectibleConditioner] async
Eventually[C Conditioner] Neverasync
Exactlyequality
Failtesting
FailNowtesting
FileEmptyFileNotEmptyfile
FileExistsFileNotExistsfile
GreaterLessOrEqualcomparison
GreaterOrEqualLesscomparison
GreaterOrEqualT[Orderable Ordered] LessTcomparison
GreaterT[Orderable Ordered] LessOrEqualTcomparison
HTTPBodyhttphelper
HTTPBodyContainsHTTPBodyNotContainshttp
HTTPErrorhttp
HTTPRedirecthttp
HTTPStatusCodehttp
HTTPSuccesshttp
ImplementsNotImplementstype
InDeltanumber
InDeltaMapValuesnumber
InDeltaSlicenumber
InDeltaT[Number Measurable] number
InEpsilonnumber
InEpsilonSlicenumber
InEpsilonSymmetricnumber
InEpsilonSymmetricT[Number Measurable] number
InEpsilonT[Number Measurable] number
IsDecreasingIsNonDecreasingordering
IsDecreasingT[OrderedSlice ~[]E, E Ordered] IsNonDecreasingTordering
IsIncreasingIsNonIncreasingordering
IsIncreasingT[OrderedSlice ~[]E, E Ordered] IsNonIncreasingTordering
IsOfTypeT[EType any] IsNotOfTypeTtype
IsTypeIsNotTypetype
JSONEqjson
JSONEqBytesjson
JSONEqT[EDoc, ADoc RText] json
JSONMarshalAsT[EDoc RText] json
JSONUnmarshalAsT[Object any, ADoc RText] json
KindNotKindtype
Lencollection
MapContainsT[Map ~map[K]V, K comparable, V any] MapNotContainsTcollection
MapEqualT[K, V comparable] MapNotEqualTcollection
NilNotNilequality
NoFileDescriptorLeaksafety
NoGoRoutineLeaksafety
ObjectsAreEqualcommonhelper
ObjectsAreEqualValuescommonhelper
PanicsNotPanicspanic
PanicsWithErrorpanic
PanicsWithValuepanic
PositiveNegativecomparison
PositiveT[SignedNumber SignedNumeric] NegativeTcomparison
RegexpNotRegexpstring
RegexpT[Rex RegExp, ADoc Text] NotRegexpTstring
SameNotSameequality
SameT[P any] NotSameTequality
SeqContainsT[E comparable] SeqNotContainsTcollection
SliceContainsT[Slice ~[]E, E comparable] SliceNotContainsTcollection
SliceEqualT[E comparable] SliceNotEqualTcollection
SliceSubsetT[Slice ~[]E, E comparable] SliceNotSubsetTcollection
SortedT[OrderedSlice ~[]E, E Ordered] NotSortedTordering
StringContainsT[ADoc, EDoc Text] StringNotContainsTcollection
SubsetNotSubsetcollection
TrueFalseboolean
TrueT[B Boolean] FalseTboolean
WithHunkSizecommonhelper
WithinDurationtime
WithinRangetime
YAMLEqyaml
YAMLEqBytesyaml
YAMLEqT[EDoc, ADoc RText] yaml
YAMLMarshalAsT[EDoc RText] yaml
YAMLUnmarshalAsT[Object any, ADoc RText] yaml
ZeroNotZerotype