Documentation
¶
Index ¶
- Variables
- type Price
- func MustNew(n, currencyCode string) Price
- func MustNewFromInt64(n int64, currencyCode string) Price
- func NewPrice(n, currencyCode string) (p Price, err error)
- func NewPriceFromCurrency(a currency.Amount) (Price, error)
- func NewPriceFromInt64(n int64, currencyCode string) (p Price, err error)
- func NewPriceFromPb(a *PricePb) (Price, error)
- type PricePb
- func (*PricePb) Descriptor() ([]byte, []int)deprecated
- func (x *PricePb) GetAmount() int64
- func (x *PricePb) GetAmountDecimal() string
- func (x *PricePb) GetCurrencyCode() string
- func (x *PricePb) GetDigits() int32
- func (x *PricePb) GetText() string
- func (*PricePb) ProtoMessage()
- func (x *PricePb) ProtoReflect() protoreflect.Message
- func (x *PricePb) Reset()
- func (x *PricePb) String() string
- func (m *PricePb) Validate() error
- func (m *PricePb) ValidateAll() error
- type PricePbMultiError
- type PricePbValidationError
Constants ¶
This section is empty.
Variables ¶
var File_price_price_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Price ¶
type Price struct { //Amount minor units (e.g. cents). for some database(like sqlite), decimal is stored as float, it may cause problems when calculating Amount int64 `json:"amount"` CurrencyCode string }
Price database friendly price struct
func MustNewFromInt64 ¶
func NewPriceFromCurrency ¶
NewPriceFromCurrency convert currency.Amount into database friendly Price
func NewPriceFromPb ¶
func (Price) ToCurrency ¶
type PricePb ¶
type PricePb struct { Amount int64 `protobuf:"varint,1,opt,name=amount,proto3" json:"amount,omitempty"` CurrencyCode string `protobuf:"bytes,2,opt,name=currency_code,json=currencyCode,proto3" json:"currency_code,omitempty"` Digits int32 `protobuf:"varint,3,opt,name=digits,proto3" json:"digits,omitempty"` Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"` AmountDecimal string `protobuf:"bytes,5,opt,name=amount_decimal,json=amountDecimal,proto3" json:"amount_decimal,omitempty"` // contains filtered or unexported fields }
func (*PricePb) Descriptor
deprecated
func (*PricePb) GetAmountDecimal ¶
func (*PricePb) GetCurrencyCode ¶
func (*PricePb) ProtoMessage ¶
func (*PricePb) ProtoMessage()
func (*PricePb) ProtoReflect ¶
func (x *PricePb) ProtoReflect() protoreflect.Message
func (*PricePb) Validate ¶
Validate checks the field values on PricePb with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*PricePb) ValidateAll ¶
ValidateAll checks the field values on PricePb with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in PricePbMultiError, or nil if none found.
type PricePbMultiError ¶
type PricePbMultiError []error
PricePbMultiError is an error wrapping multiple validation errors returned by PricePb.ValidateAll() if the designated constraints aren't met.
func (PricePbMultiError) AllErrors ¶
func (m PricePbMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (PricePbMultiError) Error ¶
func (m PricePbMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type PricePbValidationError ¶
type PricePbValidationError struct {
// contains filtered or unexported fields
}
PricePbValidationError is the validation error returned by PricePb.Validate if the designated constraints aren't met.
func (PricePbValidationError) Cause ¶
func (e PricePbValidationError) Cause() error
Cause function returns cause value.
func (PricePbValidationError) Error ¶
func (e PricePbValidationError) Error() string
Error satisfies the builtin error interface
func (PricePbValidationError) ErrorName ¶
func (e PricePbValidationError) ErrorName() string
ErrorName returns error name.
func (PricePbValidationError) Field ¶
func (e PricePbValidationError) Field() string
Field function returns field value.
func (PricePbValidationError) Key ¶
func (e PricePbValidationError) Key() bool
Key function returns key value.
func (PricePbValidationError) Reason ¶
func (e PricePbValidationError) Reason() string
Reason function returns reason value.