MCPcopy Create free account

hub / github.com/creasty/defaults / functions

Functions250 in github.com/creasty/defaults

FunctionTestSet_EmbeddedPointerStructWithoutTagStaysNil
(t *testing.T)
set_struct_test.go:109
FunctionTestSet_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
FunctionTestSet_EmptyContainerTagsAndJSONUnmarshaler
TestSet_EmptyContainerTagsAndJSONUnmarshaler pins which empty-container tags reach a custom UnmarshalJSON. The interface path withholds both `{}` and
set_unmarshaler_test.go:489
FunctionTestSet_EmptyMapTagCreatesEmptyMap
(t *testing.T)
set_map_test.go:13
FunctionTestSet_EmptySliceTagCreatesEmptySlice
(t *testing.T)
set_slice_test.go:12
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_Floats
(t *testing.T)
set_scalar_test.go:46
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_InvalidJSONInTag
(t *testing.T)
set_error_test.go:71
FunctionTestSet_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
FunctionTestSet_JSONUnmarshaler
(t *testing.T)
set_unmarshaler_test.go:240
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_MapOfPointerStructsGetsDefaults
(t *testing.T)
set_map_test.go:85
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_MapTagCreatesPointerStructElements
(t *testing.T)
set_map_test.go:158
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_MapTagJSON
(t *testing.T)
set_map_test.go:25
FunctionTestSet_NamedMapType
(t *testing.T)
set_map_test.go:36
FunctionTestSet_NamedScalarTypes
(t *testing.T)
set_scalar_test.go:282
FunctionTestSet_NamedSliceType
(t *testing.T)
set_slice_test.go:52
FunctionTestSet_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
FunctionTestSet_NestedPointersAreAllocated
TestSet_NestedPointersAreAllocated covers arbitrary pointer depth: every level is allocated and the value lands at the bottom.
set_pointer_test.go:263
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_OptOutPreservesCallerValue
(t *testing.T)
set_optout_test.go:118
FunctionTestSet_OptOutSkipsContainers
(t *testing.T)
set_optout_test.go:48
FunctionTestSet_OptOutSkipsPointer
(t *testing.T)
set_optout_test.go:61
FunctionTestSet_OptOutSkipsScalar
(t *testing.T)
set_optout_test.go:36
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_PointerToMap
(t *testing.T)
set_pointer_test.go:73
FunctionTestSet_PointerToSlice
(t *testing.T)
set_pointer_test.go:89
FunctionTestSet_PointerToStruct
(t *testing.T)
set_pointer_test.go:41
FunctionTestSet_PointerToStructWithJSONTag
(t *testing.T)
set_pointer_test.go:57
FunctionTestSet_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
FunctionTestSet_PointersToScalars
(t *testing.T)
set_pointer_test.go:12
FunctionTestSet_PreservesNonInitialMap
(t *testing.T)
set_preserve_test.go:49
FunctionTestSet_PreservesNonInitialScalar
(t *testing.T)
set_preserve_test.go:12
FunctionTestSet_PreservesNonInitialScalarPointer
(t *testing.T)
set_preserve_test.go:25
FunctionTestSet_PreservesNonInitialSlice
(t *testing.T)
set_preserve_test.go:38
FunctionTestSet_PreservesNonInitialStruct
(t *testing.T)
set_preserve_test.go:60
FunctionTestSet_PreservesNonInitialStructPointer
(t *testing.T)
set_preserve_test.go:76
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_RejectsNonStructPointer
(t *testing.T)
set_error_test.go:16
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_SignedIntegers
(t *testing.T)
set_scalar_test.go:15
FunctionTestSet_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
FunctionTestSet_SliceOfPointersFromTag
(t *testing.T)
set_slice_test.go:37
FunctionTestSet_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
FunctionTestSet_SliceOfStructsFromTag
(t *testing.T)
set_slice_test.go:78
FunctionTestSet_SliceTagJSON
(t *testing.T)
set_slice_test.go:24
FunctionTestSet_SliceTagOverridesElementDefault
TestSet_SliceTagOverridesElementDefault covers precedence between a parent's tag and a child's own default: the parent wins.
set_slice_test.go:97
FunctionTestSet_String
(t *testing.T)
set_scalar_test.go:71
FunctionTestSet_StructTagEmptyObject
(t *testing.T)
set_struct_test.go:12
FunctionTestSet_StructTagJSON
(t *testing.T)
set_struct_test.go:27
FunctionTestSet_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
FunctionTestSet_TextUnmarshaler
(t *testing.T)
set_unmarshaler_test.go:203
FunctionTestSet_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
FunctionTestSet_TextUnmarshalerPointer
(t *testing.T)
set_unmarshaler_test.go:214
FunctionTestSet_TextUnmarshalerWinsOverJSON
TestSet_TextUnmarshalerWinsOverJSON pins the precedence between the two interfaces.
set_unmarshaler_test.go:254
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSet_UnsignedIntegers
(t *testing.T)
set_scalar_test.go:30
FunctionTestSet_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
FunctionTestSet_UntaggedMapStaysNil
(t *testing.T)
set_map_test.go:51
FunctionTestSet_UntaggedPointerStaysNil
(t *testing.T)
set_pointer_test.go:105
FunctionTestSet_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
FunctionTestSet_UntaggedSliceStaysNil
(t *testing.T)
set_slice_test.go:67
FunctionTestSet_UntaggedStructRecurses
(t *testing.T)
set_struct_test.go:58
FunctionTestSet_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
FunctionTestSet_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
FunctionTestSetter_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
FunctionTestSetter_CalledOnMapElements
(t *testing.T)
setter_test.go:147
FunctionTestSetter_CalledOnMapPointerElements
(t *testing.T)
setter_test.go:158
FunctionTestSetter_CalledOnPointerField
(t *testing.T)
setter_test.go:120
← previousnext →101–200 of 250, ranked by callers