Documentation
¶
Overview ¶
Package test contains testing types and scenarios.
Index ¶
- Variables
- type FullMsgpackExtType
- type HiddenTypeAlias
- type OptionalFullMsgpackExtType
- func (o *OptionalFullMsgpackExtType) DecodeMsgpack(decoder *msgpack.Decoder) error
- func (o OptionalFullMsgpackExtType) EncodeMsgpack(encoder *msgpack.Encoder) error
- func (o OptionalFullMsgpackExtType) Get() (FullMsgpackExtType, bool)
- func (o OptionalFullMsgpackExtType) IsNil() bool
- func (o OptionalFullMsgpackExtType) IsSome() bool
- func (o OptionalFullMsgpackExtType) IsZero() bool
- func (o OptionalFullMsgpackExtType) MustGet() FullMsgpackExtType
- func (o OptionalFullMsgpackExtType) Unwrap() FullMsgpackExtType
- func (o OptionalFullMsgpackExtType) UnwrapOr(defaultValue FullMsgpackExtType) FullMsgpackExtType
- func (o OptionalFullMsgpackExtType) UnwrapOrElse(defaultValue func() FullMsgpackExtType) FullMsgpackExtType
- type OptionalHiddenTypeAlias
- func (o *OptionalHiddenTypeAlias) DecodeMsgpack(decoder *msgpack.Decoder) error
- func (o OptionalHiddenTypeAlias) EncodeMsgpack(encoder *msgpack.Encoder) error
- func (o OptionalHiddenTypeAlias) Get() (HiddenTypeAlias, bool)
- func (o OptionalHiddenTypeAlias) IsNil() bool
- func (o OptionalHiddenTypeAlias) IsSome() bool
- func (o OptionalHiddenTypeAlias) IsZero() bool
- func (o OptionalHiddenTypeAlias) MustGet() HiddenTypeAlias
- func (o OptionalHiddenTypeAlias) Unwrap() HiddenTypeAlias
- func (o OptionalHiddenTypeAlias) UnwrapOr(defaultValue HiddenTypeAlias) HiddenTypeAlias
- func (o OptionalHiddenTypeAlias) UnwrapOrElse(defaultValue func() HiddenTypeAlias) HiddenTypeAlias
- type OptionalUUID
- func (o *OptionalUUID) DecodeMsgpack(decoder *msgpack.Decoder) error
- func (o OptionalUUID) EncodeMsgpack(encoder *msgpack.Encoder) error
- func (o OptionalUUID) Get() (uuid.UUID, bool)
- func (o OptionalUUID) IsNil() bool
- func (o OptionalUUID) IsSome() bool
- func (o OptionalUUID) IsZero() bool
- func (o OptionalUUID) MustGet() uuid.UUID
- func (o OptionalUUID) Unwrap() uuid.UUID
- func (o OptionalUUID) UnwrapOr(defaultValue uuid.UUID) uuid.UUID
- func (o OptionalUUID) UnwrapOrElse(defaultValue func() uuid.UUID) uuid.UUID
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidLength is returned when the length of the input data is invalid. ErrInvalidLength = errors.New("invalid length") )
Functions ¶
This section is empty.
Types ¶
type FullMsgpackExtType ¶
FullMsgpackExtType is a test type with both MarshalMsgpack and UnmarshalMsgpack methods.
func NewEmptyFullMsgpackExtType ¶
func NewEmptyFullMsgpackExtType() (out FullMsgpackExtType)
NewEmptyFullMsgpackExtType is an empty constructor for FullMsgpackExtType.
func (*FullMsgpackExtType) MarshalMsgpack ¶
func (t *FullMsgpackExtType) MarshalMsgpack() ([]byte, error)
MarshalMsgpack .
func (*FullMsgpackExtType) UnmarshalMsgpack ¶
func (t *FullMsgpackExtType) UnmarshalMsgpack(in []byte) error
UnmarshalMsgpack .
type HiddenTypeAlias ¶
type HiddenTypeAlias = subpackage.Hidden
HiddenTypeAlias is a hidden type alias to test.
type OptionalFullMsgpackExtType ¶
type OptionalFullMsgpackExtType struct {
// contains filtered or unexported fields
}
OptionalFullMsgpackExtType represents an optional value of type FullMsgpackExtType. It can either hold a valid FullMsgpackExtType (IsSome == true) or be empty (IsZero == true).
func NoneOptionalFullMsgpackExtType ¶
func NoneOptionalFullMsgpackExtType() OptionalFullMsgpackExtType
NoneOptionalFullMsgpackExtType creates an empty optional OptionalFullMsgpackExtType value. The returned OptionalFullMsgpackExtType will have IsSome() == false and IsZero() == true.
Example:
o := NoneOptionalFullMsgpackExtType() if o.IsZero() { fmt.Println("value is absent") }
func SomeOptionalFullMsgpackExtType ¶
func SomeOptionalFullMsgpackExtType(value FullMsgpackExtType) OptionalFullMsgpackExtType
SomeOptionalFullMsgpackExtType creates an optional OptionalFullMsgpackExtType with the given FullMsgpackExtType value. The returned OptionalFullMsgpackExtType will have IsSome() == true and IsZero() == false.
func (*OptionalFullMsgpackExtType) DecodeMsgpack ¶
func (o *OptionalFullMsgpackExtType) DecodeMsgpack(decoder *msgpack.Decoder) error
DecodeMsgpack decodes a OptionalFullMsgpackExtType value from MessagePack format. Supports two input types:
- nil: interpreted as no value (NoneOptionalFullMsgpackExtType)
- FullMsgpackExtType: interpreted as a present value (SomeOptionalFullMsgpackExtType)
Returns an error if the input type is unsupported or decoding fails.
After successful decoding:
- on nil: exists = false, value = default zero value
- on FullMsgpackExtType: exists = true, value = decoded value
func (OptionalFullMsgpackExtType) EncodeMsgpack ¶
func (o OptionalFullMsgpackExtType) EncodeMsgpack(encoder *msgpack.Encoder) error
EncodeMsgpack encodes the OptionalFullMsgpackExtType value using MessagePack format. - If the value is present, it is encoded as FullMsgpackExtType. - If the value is absent (None), it is encoded as nil.
Returns an error if encoding fails.
func (OptionalFullMsgpackExtType) Get ¶
func (o OptionalFullMsgpackExtType) Get() (FullMsgpackExtType, bool)
Get returns the stored value and a boolean flag indicating its presence. If the value is present, returns (value, true). If the value is absent, returns (zero value of FullMsgpackExtType, false).
Recommended usage:
if value, ok := o.Get(); ok { // use value }
func (OptionalFullMsgpackExtType) IsNil ¶
func (o OptionalFullMsgpackExtType) IsNil() bool
IsNil is an alias for IsZero.
This method is provided for compatibility with the msgpack Encoder interface.
func (OptionalFullMsgpackExtType) IsSome ¶
func (o OptionalFullMsgpackExtType) IsSome() bool
IsSome returns true if the OptionalFullMsgpackExtType contains a value. This indicates the value is explicitly set (not None).
func (OptionalFullMsgpackExtType) IsZero ¶
func (o OptionalFullMsgpackExtType) IsZero() bool
IsZero returns true if the OptionalFullMsgpackExtType does not contain a value. Equivalent to !IsSome(). Useful for consistency with types where zero value (e.g. 0, false, zero struct) is valid and needs to be distinguished.
func (OptionalFullMsgpackExtType) MustGet ¶
func (o OptionalFullMsgpackExtType) MustGet() FullMsgpackExtType
MustGet returns the stored value if it is present. Panics if the value is absent (i.e., IsZero() == true).
Use with caution — only when you are certain the value exists.
Panics with: "optional value is not set" if no value is set.
func (OptionalFullMsgpackExtType) Unwrap ¶
func (o OptionalFullMsgpackExtType) Unwrap() FullMsgpackExtType
Unwrap returns the stored value regardless of presence. If no value is set, returns the zero value for FullMsgpackExtType.
Warning: Does not check presence. Use IsSome() before calling if you need to distinguish between absent value and explicit zero value.
func (OptionalFullMsgpackExtType) UnwrapOr ¶
func (o OptionalFullMsgpackExtType) UnwrapOr(defaultValue FullMsgpackExtType) FullMsgpackExtType
UnwrapOr returns the stored value if present. Otherwise, returns the provided default value.
Example:
o := NoneOptionalFullMsgpackExtType() v := o.UnwrapOr(someDefaultOptionalFullMsgpackExtType)
func (OptionalFullMsgpackExtType) UnwrapOrElse ¶
func (o OptionalFullMsgpackExtType) UnwrapOrElse(defaultValue func() FullMsgpackExtType) FullMsgpackExtType
UnwrapOrElse returns the stored value if present. Otherwise, calls the provided function and returns its result. Useful when the default value requires computation or side effects.
Example:
o := NoneOptionalFullMsgpackExtType() v := o.UnwrapOrElse(func() FullMsgpackExtType { return computeDefault() })
type OptionalHiddenTypeAlias ¶
type OptionalHiddenTypeAlias struct {
// contains filtered or unexported fields
}
OptionalHiddenTypeAlias represents an optional value of type HiddenTypeAlias. It can either hold a valid HiddenTypeAlias (IsSome == true) or be empty (IsZero == true).
func NoneOptionalHiddenTypeAlias ¶
func NoneOptionalHiddenTypeAlias() OptionalHiddenTypeAlias
NoneOptionalHiddenTypeAlias creates an empty optional OptionalHiddenTypeAlias value. The returned OptionalHiddenTypeAlias will have IsSome() == false and IsZero() == true.
Example:
o := NoneOptionalHiddenTypeAlias() if o.IsZero() { fmt.Println("value is absent") }
func SomeOptionalHiddenTypeAlias ¶
func SomeOptionalHiddenTypeAlias(value HiddenTypeAlias) OptionalHiddenTypeAlias
SomeOptionalHiddenTypeAlias creates an optional OptionalHiddenTypeAlias with the given HiddenTypeAlias value. The returned OptionalHiddenTypeAlias will have IsSome() == true and IsZero() == false.
func (*OptionalHiddenTypeAlias) DecodeMsgpack ¶
func (o *OptionalHiddenTypeAlias) DecodeMsgpack(decoder *msgpack.Decoder) error
DecodeMsgpack decodes a OptionalHiddenTypeAlias value from MessagePack format. Supports two input types:
- nil: interpreted as no value (NoneOptionalHiddenTypeAlias)
- HiddenTypeAlias: interpreted as a present value (SomeOptionalHiddenTypeAlias)
Returns an error if the input type is unsupported or decoding fails.
After successful decoding:
- on nil: exists = false, value = default zero value
- on HiddenTypeAlias: exists = true, value = decoded value
func (OptionalHiddenTypeAlias) EncodeMsgpack ¶
func (o OptionalHiddenTypeAlias) EncodeMsgpack(encoder *msgpack.Encoder) error
EncodeMsgpack encodes the OptionalHiddenTypeAlias value using MessagePack format. - If the value is present, it is encoded as HiddenTypeAlias. - If the value is absent (None), it is encoded as nil.
Returns an error if encoding fails.
func (OptionalHiddenTypeAlias) Get ¶
func (o OptionalHiddenTypeAlias) Get() (HiddenTypeAlias, bool)
Get returns the stored value and a boolean flag indicating its presence. If the value is present, returns (value, true). If the value is absent, returns (zero value of HiddenTypeAlias, false).
Recommended usage:
if value, ok := o.Get(); ok { // use value }
func (OptionalHiddenTypeAlias) IsNil ¶
func (o OptionalHiddenTypeAlias) IsNil() bool
IsNil is an alias for IsZero.
This method is provided for compatibility with the msgpack Encoder interface.
func (OptionalHiddenTypeAlias) IsSome ¶
func (o OptionalHiddenTypeAlias) IsSome() bool
IsSome returns true if the OptionalHiddenTypeAlias contains a value. This indicates the value is explicitly set (not None).
func (OptionalHiddenTypeAlias) IsZero ¶
func (o OptionalHiddenTypeAlias) IsZero() bool
IsZero returns true if the OptionalHiddenTypeAlias does not contain a value. Equivalent to !IsSome(). Useful for consistency with types where zero value (e.g. 0, false, zero struct) is valid and needs to be distinguished.
func (OptionalHiddenTypeAlias) MustGet ¶
func (o OptionalHiddenTypeAlias) MustGet() HiddenTypeAlias
MustGet returns the stored value if it is present. Panics if the value is absent (i.e., IsZero() == true).
Use with caution — only when you are certain the value exists.
Panics with: "optional value is not set" if no value is set.
func (OptionalHiddenTypeAlias) Unwrap ¶
func (o OptionalHiddenTypeAlias) Unwrap() HiddenTypeAlias
Unwrap returns the stored value regardless of presence. If no value is set, returns the zero value for HiddenTypeAlias.
Warning: Does not check presence. Use IsSome() before calling if you need to distinguish between absent value and explicit zero value.
func (OptionalHiddenTypeAlias) UnwrapOr ¶
func (o OptionalHiddenTypeAlias) UnwrapOr(defaultValue HiddenTypeAlias) HiddenTypeAlias
UnwrapOr returns the stored value if present. Otherwise, returns the provided default value.
Example:
o := NoneOptionalHiddenTypeAlias() v := o.UnwrapOr(someDefaultOptionalHiddenTypeAlias)
func (OptionalHiddenTypeAlias) UnwrapOrElse ¶
func (o OptionalHiddenTypeAlias) UnwrapOrElse(defaultValue func() HiddenTypeAlias) HiddenTypeAlias
UnwrapOrElse returns the stored value if present. Otherwise, calls the provided function and returns its result. Useful when the default value requires computation or side effects.
Example:
o := NoneOptionalHiddenTypeAlias() v := o.UnwrapOrElse(func() HiddenTypeAlias { return computeDefault() })
type OptionalUUID ¶
type OptionalUUID struct {
// contains filtered or unexported fields
}
OptionalUUID represents an optional value of type uuid.UUID. It can either hold a valid uuid.UUID (IsSome == true) or be empty (IsZero == true).
func NoneOptionalUUID ¶
func NoneOptionalUUID() OptionalUUID
NoneOptionalUUID creates an empty optional OptionalUUID value. The returned OptionalUUID will have IsSome() == false and IsZero() == true.
Example:
o := NoneOptionalUUID() if o.IsZero() { fmt.Println("value is absent") }
func SomeOptionalUUID ¶
func SomeOptionalUUID(value uuid.UUID) OptionalUUID
SomeOptionalUUID creates an optional OptionalUUID with the given uuid.UUID value. The returned OptionalUUID will have IsSome() == true and IsZero() == false.
func (*OptionalUUID) DecodeMsgpack ¶
func (o *OptionalUUID) DecodeMsgpack(decoder *msgpack.Decoder) error
DecodeMsgpack decodes a OptionalUUID value from MessagePack format. Supports two input types:
- nil: interpreted as no value (NoneOptionalUUID)
- uuid.UUID: interpreted as a present value (SomeOptionalUUID)
Returns an error if the input type is unsupported or decoding fails.
After successful decoding:
- on nil: exists = false, value = default zero value
- on uuid.UUID: exists = true, value = decoded value
func (OptionalUUID) EncodeMsgpack ¶
func (o OptionalUUID) EncodeMsgpack(encoder *msgpack.Encoder) error
EncodeMsgpack encodes the OptionalUUID value using MessagePack format. - If the value is present, it is encoded as uuid.UUID. - If the value is absent (None), it is encoded as nil.
Returns an error if encoding fails.
func (OptionalUUID) Get ¶
func (o OptionalUUID) Get() (uuid.UUID, bool)
Get returns the stored value and a boolean flag indicating its presence. If the value is present, returns (value, true). If the value is absent, returns (zero value of uuid.UUID, false).
Recommended usage:
if value, ok := o.Get(); ok { // use value }
func (OptionalUUID) IsNil ¶
func (o OptionalUUID) IsNil() bool
IsNil is an alias for IsZero.
This method is provided for compatibility with the msgpack Encoder interface.
func (OptionalUUID) IsSome ¶
func (o OptionalUUID) IsSome() bool
IsSome returns true if the OptionalUUID contains a value. This indicates the value is explicitly set (not None).
func (OptionalUUID) IsZero ¶
func (o OptionalUUID) IsZero() bool
IsZero returns true if the OptionalUUID does not contain a value. Equivalent to !IsSome(). Useful for consistency with types where zero value (e.g. 0, false, zero struct) is valid and needs to be distinguished.
func (OptionalUUID) MustGet ¶
func (o OptionalUUID) MustGet() uuid.UUID
MustGet returns the stored value if it is present. Panics if the value is absent (i.e., IsZero() == true).
Use with caution — only when you are certain the value exists.
Panics with: "optional value is not set" if no value is set.
func (OptionalUUID) Unwrap ¶
func (o OptionalUUID) Unwrap() uuid.UUID
Unwrap returns the stored value regardless of presence. If no value is set, returns the zero value for uuid.UUID.
Warning: Does not check presence. Use IsSome() before calling if you need to distinguish between absent value and explicit zero value.
func (OptionalUUID) UnwrapOr ¶
func (o OptionalUUID) UnwrapOr(defaultValue uuid.UUID) uuid.UUID
UnwrapOr returns the stored value if present. Otherwise, returns the provided default value.
Example:
o := NoneOptionalUUID() v := o.UnwrapOr(someDefaultOptionalUUID)
func (OptionalUUID) UnwrapOrElse ¶
func (o OptionalUUID) UnwrapOrElse(defaultValue func() uuid.UUID) uuid.UUID
UnwrapOrElse returns the stored value if present. Otherwise, calls the provided function and returns its result. Useful when the default value requires computation or side effects.
Example:
o := NoneOptionalUUID() v := o.UnwrapOrElse(func() uuid.UUID { return computeDefault() })
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package subpackage contains a hidden type for testing type aliases generation.
|
Package subpackage contains a hidden type for testing type aliases generation. |