// Code generated by go-enum DO NOT EDIT. // Version: - // Revision: - // Build Date: - // Built By: - package consts import ( "database/sql/driver" "errors" "fmt" "strings" ) const ( // CouponTypeFixAmount is a CouponType of type fix_amount. CouponTypeFixAmount CouponType = "fix_amount" // CouponTypeDiscount is a CouponType of type discount. CouponTypeDiscount CouponType = "discount" ) var ErrInvalidCouponType = fmt.Errorf("not a valid CouponType, try [%s]", strings.Join(_CouponTypeNames, ", ")) var _CouponTypeNames = []string{ string(CouponTypeFixAmount), string(CouponTypeDiscount), } // CouponTypeNames returns a list of possible string values of CouponType. func CouponTypeNames() []string { tmp := make([]string, len(_CouponTypeNames)) copy(tmp, _CouponTypeNames) return tmp } // CouponTypeValues returns a list of the values for CouponType func CouponTypeValues() []CouponType { return []CouponType{ CouponTypeFixAmount, CouponTypeDiscount, } } // String implements the Stringer interface. func (x CouponType) String() string { return string(x) } // IsValid provides a quick way to determine if the typed value is // part of the allowed enumerated values func (x CouponType) IsValid() bool { _, err := ParseCouponType(string(x)) return err == nil } var _CouponTypeValue = map[string]CouponType{ "fix_amount": CouponTypeFixAmount, "discount": CouponTypeDiscount, } // ParseCouponType attempts to convert a string to a CouponType. func ParseCouponType(name string) (CouponType, error) { if x, ok := _CouponTypeValue[name]; ok { return x, nil } return CouponType(""), fmt.Errorf("%s is %w", name, ErrInvalidCouponType) } var errCouponTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes // Scan implements the Scanner interface. func (x *CouponType) Scan(value interface{}) (err error) { if value == nil { *x = CouponType("") return } // A wider range of scannable types. // driver.Value values at the top of the list for expediency switch v := value.(type) { case string: *x, err = ParseCouponType(v) case []byte: *x, err = ParseCouponType(string(v)) case CouponType: *x = v case *CouponType: if v == nil { return errCouponTypeNilPtr } *x = *v case *string: if v == nil { return errCouponTypeNilPtr } *x, err = ParseCouponType(*v) default: return errors.New("invalid type for CouponType") } return } // Value implements the driver Valuer interface. func (x CouponType) Value() (driver.Value, error) { return x.String(), nil } // Set implements the Golang flag.Value interface func. func (x *CouponType) Set(val string) error { v, err := ParseCouponType(val) *x = v return err } // Get implements the Golang flag.Getter interface func. func (x *CouponType) Get() interface{} { return *x } // Type implements the github.com/spf13/pFlag Value interface. func (x *CouponType) Type() string { return "CouponType" } type NullCouponType struct { CouponType CouponType Valid bool } func NewNullCouponType(val interface{}) (x NullCouponType) { err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value. _ = err // make any errcheck linters happy return } // Scan implements the Scanner interface. func (x *NullCouponType) Scan(value interface{}) (err error) { if value == nil { x.CouponType, x.Valid = CouponType(""), false return } err = x.CouponType.Scan(value) x.Valid = (err == nil) return } // Value implements the driver Valuer interface. func (x NullCouponType) Value() (driver.Value, error) { if !x.Valid { return nil, nil } // driver.Value accepts int64 for int values. return string(x.CouponType), nil } type NullCouponTypeStr struct { NullCouponType } func NewNullCouponTypeStr(val interface{}) (x NullCouponTypeStr) { x.Scan(val) // yes, we ignore this error, it will just be an invalid value. return } // Value implements the driver Valuer interface. func (x NullCouponTypeStr) Value() (driver.Value, error) { if !x.Valid { return nil, nil } return x.CouponType.String(), nil } const ( // UserCouponStatusUnused is a UserCouponStatus of type unused. UserCouponStatusUnused UserCouponStatus = "unused" // UserCouponStatusUsed is a UserCouponStatus of type used. UserCouponStatusUsed UserCouponStatus = "used" // UserCouponStatusExpired is a UserCouponStatus of type expired. UserCouponStatusExpired UserCouponStatus = "expired" ) var ErrInvalidUserCouponStatus = fmt.Errorf("not a valid UserCouponStatus, try [%s]", strings.Join(_UserCouponStatusNames, ", ")) var _UserCouponStatusNames = []string{ string(UserCouponStatusUnused), string(UserCouponStatusUsed), string(UserCouponStatusExpired), } // UserCouponStatusNames returns a list of possible string values of UserCouponStatus. func UserCouponStatusNames() []string { tmp := make([]string, len(_UserCouponStatusNames)) copy(tmp, _UserCouponStatusNames) return tmp } // UserCouponStatusValues returns a list of the values for UserCouponStatus func UserCouponStatusValues() []UserCouponStatus { return []UserCouponStatus{ UserCouponStatusUnused, UserCouponStatusUsed, UserCouponStatusExpired, } } // String implements the Stringer interface. func (x UserCouponStatus) String() string { return string(x) } // IsValid provides a quick way to determine if the typed value is // part of the allowed enumerated values func (x UserCouponStatus) IsValid() bool { _, err := ParseUserCouponStatus(string(x)) return err == nil } var _UserCouponStatusValue = map[string]UserCouponStatus{ "unused": UserCouponStatusUnused, "used": UserCouponStatusUsed, "expired": UserCouponStatusExpired, } // ParseUserCouponStatus attempts to convert a string to a UserCouponStatus. func ParseUserCouponStatus(name string) (UserCouponStatus, error) { if x, ok := _UserCouponStatusValue[name]; ok { return x, nil } return UserCouponStatus(""), fmt.Errorf("%s is %w", name, ErrInvalidUserCouponStatus) } var errUserCouponStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes // Scan implements the Scanner interface. func (x *UserCouponStatus) Scan(value interface{}) (err error) { if value == nil { *x = UserCouponStatus("") return } // A wider range of scannable types. // driver.Value values at the top of the list for expediency switch v := value.(type) { case string: *x, err = ParseUserCouponStatus(v) case []byte: *x, err = ParseUserCouponStatus(string(v)) case UserCouponStatus: *x = v case *UserCouponStatus: if v == nil { return errUserCouponStatusNilPtr } *x = *v case *string: if v == nil { return errUserCouponStatusNilPtr } *x, err = ParseUserCouponStatus(*v) default: return errors.New("invalid type for UserCouponStatus") } return } // Value implements the driver Valuer interface. func (x UserCouponStatus) Value() (driver.Value, error) { return x.String(), nil } // Set implements the Golang flag.Value interface func. func (x *UserCouponStatus) Set(val string) error { v, err := ParseUserCouponStatus(val) *x = v return err } // Get implements the Golang flag.Getter interface func. func (x *UserCouponStatus) Get() interface{} { return *x } // Type implements the github.com/spf13/pFlag Value interface. func (x *UserCouponStatus) Type() string { return "UserCouponStatus" } type NullUserCouponStatus struct { UserCouponStatus UserCouponStatus Valid bool } func NewNullUserCouponStatus(val interface{}) (x NullUserCouponStatus) { err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value. _ = err // make any errcheck linters happy return } // Scan implements the Scanner interface. func (x *NullUserCouponStatus) Scan(value interface{}) (err error) { if value == nil { x.UserCouponStatus, x.Valid = UserCouponStatus(""), false return } err = x.UserCouponStatus.Scan(value) x.Valid = (err == nil) return } // Value implements the driver Valuer interface. func (x NullUserCouponStatus) Value() (driver.Value, error) { if !x.Valid { return nil, nil } // driver.Value accepts int64 for int values. return string(x.UserCouponStatus), nil } type NullUserCouponStatusStr struct { NullUserCouponStatus } func NewNullUserCouponStatusStr(val interface{}) (x NullUserCouponStatusStr) { x.Scan(val) // yes, we ignore this error, it will just be an invalid value. return } // Value implements the driver Valuer interface. func (x NullUserCouponStatusStr) Value() (driver.Value, error) { if !x.Valid { return nil, nil } return x.UserCouponStatus.String(), nil }