Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/creasty/defaults
/ functions
Functions
250 in github.com/creasty/defaults
⨍
Functions
250
◇
Types & classes
149
Function
TestSet_EmbeddedPointerStructWithoutTagStaysNil
(t *testing.T)
set_struct_test.go:109
Function
TestSet_EmbeddedStruct
TestSet_EmbeddedStruct covers promoted fields. The embedded types are named with an initial capital on purpose: the embedded field takes the type's na
set_struct_test.go:75
Function
TestSet_EmptyContainerTagsAndJSONUnmarshaler
TestSet_EmptyContainerTagsAndJSONUnmarshaler pins which empty-container tags reach a custom UnmarshalJSON. The interface path withholds both `{}` and
set_unmarshaler_test.go:489
Function
TestSet_EmptyMapTagCreatesEmptyMap
(t *testing.T)
set_map_test.go:13
Function
TestSet_EmptySliceTagCreatesEmptySlice
(t *testing.T)
set_slice_test.go:12
Function
TestSet_EmptyTag
TestSet_EmptyTag covers `default:""`, which is a request for the zero value rather than an absence: Set reads the tag with Tag.Lookup, so an empty tag
set_scalar_test.go:420
Function
TestSet_ErrorStopsAtTheFirstField
TestSet_ErrorStopsAtTheFirstField pins that Set gives up on the first failing field rather than collecting errors, so later fields keep their zero val
set_error_test.go:160
Function
TestSet_FailingDefaultKeepsWhatWasNotZero
TestSet_FailingDefaultKeepsWhatWasNotZero pins the other side: a value Set did not find zero is not put back, so the caller's slice or map survives a
set_error_test.go:232
Function
TestSet_FailingDefaultLeavesZeroValuesZero
TestSet_FailingDefaultLeavesZeroValuesZero pins that a value Set found zero is zero again when a default below it fails, so a second Set meets the sam
set_error_test.go:176
Function
TestSet_FailingUnmarshalerErrorIsReported
TestSet_FailingUnmarshalerErrorIsReported covers a tag the type's own unmarshaler rejects and parsing by kind cannot take either. The error Set return
set_unmarshaler_test.go:405
Function
TestSet_FailingUnmarshalerFallsBackToKind
TestSet_FailingUnmarshalerFallsBackToKind covers what happens when the type's own unmarshaler rejects the value: the value is parsed by kind instead,
set_unmarshaler_test.go:354
Function
TestSet_FailingUnmarshalerWithNothingToFallBackTo
TestSet_FailingUnmarshalerWithNothingToFallBackTo covers a tag the type's own unmarshaler rejects when setField does not parse the type's kind at all:
set_unmarshaler_test.go:446
Function
TestSet_Floats
(t *testing.T)
set_scalar_test.go:46
Function
TestSet_IntegerLiteralBases
TestSet_IntegerLiteralBases covers every width against every base, because the base is a parameter of the strconv call made per width: a `ParseInt(v,
set_scalar_test.go:87
Function
TestSet_InterfaceFieldsAreNotFollowed
TestSet_InterfaceFieldsAreNotFollowed pins that a non-nil interface is not descended into, even when it holds a pointer to a struct carrying tags. The
set_scalar_test.go:466
Function
TestSet_InvalidDefaultErrorShape
TestSet_InvalidDefaultErrorShape pins what the error carries: the field it came from, the tag that failed, and the underlying cause still reachable —
set_scalar_test.go:396
Function
TestSet_InvalidJSONInTag
(t *testing.T)
set_error_test.go:71
Function
TestSet_InvalidTypeKeepsItsMessage
TestSet_InvalidTypeKeepsItsMessage pins the message of ErrInvalidType. Until the error was exported, matching on its message was the only way to tell
set_error_test.go:67
Function
TestSet_JSONUnmarshaler
(t *testing.T)
set_unmarshaler_test.go:240
Function
TestSet_LeadingZeroIsOctal
TestSet_LeadingZeroIsOctal pins that an integer tag is a Go integer literal all the way, legacy octal included: a leading zero makes the rest octal, s
set_scalar_test.go:159
Function
TestSet_MapContainerValueIsNotStoredBack
TestSet_MapContainerValueIsNotStoredBack covers a slice or map held as a map value. Set fills a copy of it too, but the copy refers to the same elemen
set_map_test.go:269
Function
TestSet_MapEntryUnderNaNKeyIsSkipped
TestSet_MapEntryUnderNaNKeyIsSkipped pins that an entry whose key is NaN gets no defaults. Each value is looked up by its key, and NaN never equals it
set_map_test.go:363
Function
TestSet_MapOfNilPointersIsLeftAlone
TestSet_MapOfNilPointersIsLeftAlone covers a nil pointer as a map value: there is nothing behind it to recurse into. A pointer map value is written th
set_map_test.go:111
Function
TestSet_MapOfPointerContainers
TestSet_MapOfPointerContainers covers map values that point at a container rather than a struct. The element loop handles all three of struct, slice a
set_map_test.go:190
Function
TestSet_MapOfPointerStructsGetsDefaults
(t *testing.T)
set_map_test.go:85
Function
TestSet_MapOfScalarsIsLeftAlone
TestSet_MapOfScalarsIsLeftAlone pins that scalar map values are never rewritten: a zero value is not a field with a tag.
set_map_test.go:177
Function
TestSet_MapOfStructsGetsDefaults
TestSet_MapOfStructsGetsDefaults covers a map of struct values the caller filled in. Values are not addressable, so each element is copied, defaulted,
set_map_test.go:64
Function
TestSet_MapStructValueIsStoredBack
TestSet_MapStructValueIsStoredBack pins that a struct held as a map value is stored back under its key once its copy is filled, whether or not anythin
set_map_test.go:237
Function
TestSet_MapTagCreatesPointerStructElements
(t *testing.T)
set_map_test.go:158
Function
TestSet_MapTagCreatesStructElements
TestSet_MapTagCreatesStructElements covers elements the tag itself creates: they are defaulted like any other element, and no other key appears.
set_map_test.go:141
Function
TestSet_MapTagIsNotReappliedToElements
TestSet_MapTagIsNotReappliedToElements pins that the element recursion is handed an empty tag: the parent's JSON builds the map once and is not decode
set_map_test.go:387
Function
TestSet_MapTagJSON
(t *testing.T)
set_map_test.go:25
Function
TestSet_NamedMapType
(t *testing.T)
set_map_test.go:36
Function
TestSet_NamedScalarTypes
(t *testing.T)
set_scalar_test.go:282
Function
TestSet_NamedSliceType
(t *testing.T)
set_slice_test.go:52
Function
TestSet_NestedContainers
TestSet_NestedContainers covers containers nested inside one another, whether the caller built them or a tag did: the structs at the bottom get their
set_nesting_test.go:14
Function
TestSet_NestedPointersAreAllocated
TestSet_NestedPointersAreAllocated covers arbitrary pointer depth: every level is allocated and the value lands at the bottom.
set_pointer_test.go:263
Function
TestSet_NumberTagIsNotTrimmed
TestSet_NumberTagIsNotTrimmed pins the other side of that trim: it belongs to the duration attempt alone, so a padded number reaches the numeric parse
set_duration_test.go:139
Function
TestSet_NumericWidthBoundaries
TestSet_NumericWidthBoundaries pins the bit size each numeric case parses with. Every case passes that width to strconv as a literal, and a wrong one
set_scalar_test.go:207
Function
TestSet_OptOutDoesNotAffectOwnSetter
TestSet_OptOutDoesNotAffectOwnSetter covers the other side: opting a field out does not opt its own struct out of having its setter called.
set_optout_test.go:110
Function
TestSet_OptOutPreservesCallerValue
(t *testing.T)
set_optout_test.go:118
Function
TestSet_OptOutSkipsContainers
(t *testing.T)
set_optout_test.go:48
Function
TestSet_OptOutSkipsPointer
(t *testing.T)
set_optout_test.go:61
Function
TestSet_OptOutSkipsScalar
(t *testing.T)
set_optout_test.go:36
Function
TestSet_OptOutSkipsStructRecursionAndSetter
TestSet_OptOutSkipsStructRecursionAndSetter covers the reach of `-` on a struct field: it is not descended into, so neither the nested tags nor the ne
set_optout_test.go:82
Function
TestSet_PointerFieldErrorIsReported
TestSet_PointerFieldErrorIsReported covers a *struct field whose nested tag is invalid. That error used to be discarded, alone among the recursions, s
set_error_test.go:134
Function
TestSet_PointerToMap
(t *testing.T)
set_pointer_test.go:73
Function
TestSet_PointerToSlice
(t *testing.T)
set_pointer_test.go:89
Function
TestSet_PointerToStruct
(t *testing.T)
set_pointer_test.go:41
Function
TestSet_PointerToStructWithJSONTag
(t *testing.T)
set_pointer_test.go:57
Function
TestSet_PointerWithEmptyTag
TestSet_PointerWithEmptyTag covers `default:""` on a pointer. The tag is present, so the pointer is allocated and points at the zero value — it used t
set_pointer_test.go:246
Function
TestSet_PointersToScalars
(t *testing.T)
set_pointer_test.go:12
Function
TestSet_PreservesNonInitialMap
(t *testing.T)
set_preserve_test.go:49
Function
TestSet_PreservesNonInitialScalar
(t *testing.T)
set_preserve_test.go:12
Function
TestSet_PreservesNonInitialScalarPointer
(t *testing.T)
set_preserve_test.go:25
Function
TestSet_PreservesNonInitialSlice
(t *testing.T)
set_preserve_test.go:38
Function
TestSet_PreservesNonInitialStruct
(t *testing.T)
set_preserve_test.go:60
Function
TestSet_PreservesNonInitialStructPointer
(t *testing.T)
set_preserve_test.go:76
Function
TestSet_PreservesNonInitialZeroLengthContainers
TestSet_PreservesNonInitialZeroLengthContainers pins that "non-initial" means "not deep-equal to the zero value", so an allocated but empty slice or m
set_preserve_test.go:116
Function
TestSet_RecursiveTypeEnds
TestSet_RecursiveTypeEnds covers types that repeat without their default recursing, which Set must walk to the end rather than reject. A repeat counts
set_recursion_test.go:74
Function
TestSet_RejectsDefaultThatRecursesWithoutEnd
TestSet_RejectsDefaultThatRecursesWithoutEnd covers a type that refers to itself through a field whose tag creates what it refers to: the default fill
set_recursion_test.go:19
Function
TestSet_RejectsNil
TestSet_RejectsNil covers a nil, typed or not, which has no struct behind it to fill: it is rejected with the same error as any other non-struct-point
set_error_test.go:50
Function
TestSet_RejectsNonStructPointer
(t *testing.T)
set_error_test.go:16
Function
TestSet_SharedValueIsFilledOncePerPath
TestSet_SharedValueIsFilledOncePerPath covers a value the caller made reachable by more than one path. Set knows only the values on the path it is wal
set_shared_test.go:32
Function
TestSet_SharedValueIsFilledOncePerPathAtAnyDepth
TestSet_SharedValueIsFilledOncePerPathAtAnyDepth covers values shared far down a long path, where Set looks a value up in an index of the path instead
set_shared_test.go:112
Function
TestSet_SignedIntegers
(t *testing.T)
set_scalar_test.go:15
Function
TestSet_SliceElementsGetDefaults
TestSet_SliceElementsGetDefaults covers a slice the caller filled in: Set descends into each element even though the field carries no tag.
set_slice_test.go:113
Function
TestSet_SliceOfPointersFromTag
(t *testing.T)
set_slice_test.go:37
Function
TestSet_SliceOfScalarsIsLeftAlone
TestSet_SliceOfScalarsIsLeftAlone pins that elements of a scalar slice are never rewritten: a zero element is not a field with a tag, so nothing appli
set_slice_test.go:133
Function
TestSet_SliceOfStructsFromTag
(t *testing.T)
set_slice_test.go:78
Function
TestSet_SliceTagJSON
(t *testing.T)
set_slice_test.go:24
Function
TestSet_SliceTagOverridesElementDefault
TestSet_SliceTagOverridesElementDefault covers precedence between a parent's tag and a child's own default: the parent wins.
set_slice_test.go:97
Function
TestSet_String
(t *testing.T)
set_scalar_test.go:71
Function
TestSet_StructTagEmptyObject
(t *testing.T)
set_struct_test.go:12
Function
TestSet_StructTagJSON
(t *testing.T)
set_struct_test.go:27
Function
TestSet_StructTagJSONWins
TestSet_StructTagJSONWins covers precedence: what the parent's JSON provides is not overwritten by the child's own default.
set_struct_test.go:44
Function
TestSet_TextUnmarshaler
(t *testing.T)
set_unmarshaler_test.go:203
Function
TestSet_TextUnmarshalerArray
TestSet_TextUnmarshalerArray covers an array type with a text form, the shape of uuid.UUID. setField does not parse an array by kind, but the tag is o
set_unmarshaler_test.go:229
Function
TestSet_TextUnmarshalerPointer
(t *testing.T)
set_unmarshaler_test.go:214
Function
TestSet_TextUnmarshalerWinsOverJSON
TestSet_TextUnmarshalerWinsOverJSON pins the precedence between the two interfaces.
set_unmarshaler_test.go:254
Function
TestSet_TextUnmarshalerWinsOverSetter
TestSet_TextUnmarshalerWinsOverSetter pins the precedence the README claims. A successful UnmarshalText returns out of setField ahead of the recursion
set_unmarshaler_test.go:280
Function
TestSet_TimeTime
TestSet_TimeTime covers the stdlib struct most likely to carry a default tag. It reaches time.Time's UnmarshalText, and a value that does not parse is
set_unmarshaler_test.go:574
Function
TestSet_UnexportedCompositeFieldsAreSkippedWholesale
TestSet_UnexportedCompositeFieldsAreSkippedWholesale pins how far the CanSet guard reaches: an unexported field is skipped whatever its type, so a who
set_unexported_test.go:39
Function
TestSet_UnexportedEmbeddedStructIsSkippedWholesale
TestSet_UnexportedEmbeddedStructIsSkippedWholesale pins that the setter goes unapplied along with the tags when the unexported field is embedded; the
set_unexported_test.go:73
Function
TestSet_UnexportedScalarFieldIsSkipped
TestSet_UnexportedScalarFieldIsSkipped pins that an unexported field is untouched even with a tag (reflect cannot set it), and that its presence does
set_unexported_test.go:23
Function
TestSet_UnmarshalerNeedsANonEmptyTag
TestSet_UnmarshalerNeedsANonEmptyTag pins that neither interface is consulted for an empty tag, so a type that could unmarshal anything gets nothing f
set_unmarshaler_test.go:605
Function
TestSet_UnparsableValuesAreRejected
TestSet_UnparsableValuesAreRejected covers a value the field's kind cannot parse: Set now returns an error naming the field, where it used to leave th
set_scalar_test.go:337
Function
TestSet_UnsignedIntegers
(t *testing.T)
set_scalar_test.go:30
Function
TestSet_UnsupportedKindsAreIgnored
TestSet_UnsupportedKindsAreIgnored pins that kinds setField has no case for are left alone, tag or no tag, without an error. Only a tag that a type's
set_scalar_test.go:446
Function
TestSet_UntaggedMapStaysNil
(t *testing.T)
set_map_test.go:51
Function
TestSet_UntaggedPointerStaysNil
(t *testing.T)
set_pointer_test.go:105
Function
TestSet_UntaggedPointerStructRecurses
TestSet_UntaggedPointerStructRecurses covers the pointer a caller has already allocated: even with no tag, Set descends into it and fills its fields.
set_pointer_test.go:125
Function
TestSet_UntaggedSliceStaysNil
(t *testing.T)
set_slice_test.go:67
Function
TestSet_UntaggedStructRecurses
(t *testing.T)
set_struct_test.go:58
Function
TestSet_WellFormedJSONOfTheWrongShape
TestSet_WellFormedJSONOfTheWrongShape covers the other way decoding fails: valid JSON that cannot land in the field's type. It surfaces as *json.Unmar
set_error_test.go:268
Function
TestSet_WhitespaceTagIsNotEmpty
TestSet_WhitespaceTagIsNotEmpty pins that a stray space is a value rather than an absence: a string takes it verbatim, and every container tries to de
set_error_test.go:284
Function
TestSetter_CalledOnGenericStruct
TestSetter_CalledOnGenericStruct pins that a generic type's own setter is called. The compiler instantiates a generic method's code itself, so this gu
setter_test.go:447
Function
TestSetter_CalledOnMapElements
(t *testing.T)
setter_test.go:147
Function
TestSetter_CalledOnMapPointerElements
(t *testing.T)
setter_test.go:158
Function
TestSetter_CalledOnPointerField
(t *testing.T)
setter_test.go:120
← previous
next →
101–200 of 250, ranked by callers