Documentation
¶
Index ¶
- Variables
- func ExhaustiveDiscountTypes(f func(DiscountType))
- type DiscountType
- func (d DiscountType) IsValid() bool
- func (d DiscountType) MarshalBinary() ([]byte, error)
- func (d DiscountType) MarshalJSON() ([]byte, error)
- func (d DiscountType) MarshalText() ([]byte, error)
- func (d DiscountType) MarshalYAML() ([]byte, error)
- func (d *DiscountType) Scan(value any) error
- func (d DiscountType) String() string
- func (d *DiscountType) UnmarshalBinary(b []byte) error
- func (d *DiscountType) UnmarshalJSON(b []byte) error
- func (d *DiscountType) UnmarshalText(b []byte) error
- func (d *DiscountType) UnmarshalYAML(b []byte) error
- func (d DiscountType) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
var DiscountTypes = discountTypesContainer{ SALE: DiscountType{ Available: false, Started: true, Finished: true, Cancelled: false, Duration: time.Hour * 172, // contains filtered or unexported fields }, PERCENTAGE: DiscountType{ Available: false, Started: false, Finished: false, Cancelled: false, Duration: time.Hour * 24, // contains filtered or unexported fields }, AMOUNT: DiscountType{ Available: false, Started: false, Finished: false, Cancelled: false, Duration: time.Hour * 48, // contains filtered or unexported fields }, GIVEAWAY: DiscountType{ Available: true, Started: true, Finished: false, Cancelled: false, Duration: time.Hour * 72, // contains filtered or unexported fields }, }
DiscountTypes is a main entry point using the DiscountType type. It it a container for all enum values and provides a convenient way to access all enum values and perform operations, with convenience methods for common use cases.
var ErrParseDiscountType = errors.New("invalid input provided to parse to DiscountType")
Functions ¶
func ExhaustiveDiscountTypes ¶
func ExhaustiveDiscountTypes(f func(DiscountType))
ExhaustiveDiscountTypes iterates over all enum values and calls the provided function for each value. This function is useful for performing operations on all valid enum values in a loop.
Types ¶
type DiscountType ¶
type DiscountType struct { Available bool Started bool Finished bool Cancelled bool Duration time.Duration // contains filtered or unexported fields }
DiscountType is a type that represents a single enum value. It combines the core information about the enum constant and it's defined fields.
func ParseDiscountType ¶
func ParseDiscountType(input any) (DiscountType, error)
ParseDiscountType parses the input value into an enum value. It returns the parsed enum value or an error if the input is invalid. It is a convenience function that can be used to parse enum values from various input types, such as strings, byte slices, or other enum types.
func (DiscountType) IsValid ¶
func (d DiscountType) IsValid() bool
IsValid checks whether the DiscountTypes value is valid. A valid value is one that is defined in the original enum and not marked as invalid.
func (DiscountType) MarshalBinary ¶ added in v0.3.8
func (d DiscountType) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface for DiscountType. It returns the binary representation of the enum value as a byte slice.
func (DiscountType) MarshalJSON ¶
func (d DiscountType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for DiscountType. It returns the JSON representation of the enum value as a byte slice.
func (DiscountType) MarshalText ¶ added in v0.3.8
func (d DiscountType) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for DiscountType. It returns the string representation of the enum value as a byte slice
func (DiscountType) MarshalYAML ¶ added in v0.4.0
func (d DiscountType) MarshalYAML() ([]byte, error)
MarshalYAML implements the yaml.Marshaler interface for DiscountType. It returns the string representation of the enum value.
func (*DiscountType) Scan ¶
func (d *DiscountType) Scan(value any) error
Scan implements the database/sql.Scanner interface for DiscountType. It parses the string representation of the enum value from the database row. It returns an error if the row does not contain a valid enum value.
func (DiscountType) String ¶
func (d DiscountType) String() string
String implements the Stringer interface. It returns the canonical absolute name of the enum value.
func (*DiscountType) UnmarshalBinary ¶ added in v0.3.8
func (d *DiscountType) UnmarshalBinary(b []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for DiscountType. It parses the binary representation of the enum value from the byte slice. It returns an error if the byte slice does not contain a valid enum value.
func (*DiscountType) UnmarshalJSON ¶
func (d *DiscountType) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for DiscountType. It parses the JSON representation of the enum value from the byte slice. It returns an error if the input is not a valid JSON representation.
func (*DiscountType) UnmarshalText ¶ added in v0.3.8
func (d *DiscountType) UnmarshalText(b []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for DiscountType. It parses the string representation of the enum value from the byte slice. It returns an error if the byte slice does not contain a valid enum value.
func (*DiscountType) UnmarshalYAML ¶ added in v0.4.0
func (d *DiscountType) UnmarshalYAML(b []byte) error
UnmarshalYAML implements the yaml.Unmarshaler interface for Planet. It parses the byte slice representation of the enum value and returns an error if the YAML byte slice does not contain a valid enum value.