本文整理匯總了Golang中github.com/go-openapi/swag.IsZero函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsZero函數的具體用法?Golang IsZero怎麽用?Golang IsZero使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IsZero函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ShouldBeEquivalentTo
func ShouldBeEquivalentTo(actual interface{}, expecteds ...interface{}) string {
expected := expecteds[0]
if actual == nil || expected == nil {
return ""
}
if reflect.DeepEqual(expected, actual) {
return ""
}
actualType := reflect.TypeOf(actual)
expectedType := reflect.TypeOf(expected)
if reflect.TypeOf(actual).ConvertibleTo(expectedType) {
expectedValue := reflect.ValueOf(expected)
if swag.IsZero(expectedValue) && swag.IsZero(reflect.ValueOf(actual)) {
return ""
}
// Attempt comparison after type conversion
if reflect.DeepEqual(actual, expectedValue.Convert(actualType).Interface()) {
return ""
}
}
// Last ditch effort
if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) {
return ""
}
errFmt := "Expected: '%T(%#v)'\nActual: '%T(%#v)'\n(Should be equivalent)!"
return fmt.Sprintf(errFmt, expected, expected, actual, actual)
}
示例2: assertEquivalent
func assertEquivalent(t testing.TB, actual, expected interface{}) bool {
if actual == nil || expected == nil || reflect.DeepEqual(actual, expected) {
return true
}
actualType := reflect.TypeOf(actual)
expectedType := reflect.TypeOf(expected)
if reflect.TypeOf(actual).ConvertibleTo(expectedType) {
expectedValue := reflect.ValueOf(expected)
if swag.IsZero(expectedValue) && swag.IsZero(reflect.ValueOf(actual)) {
return true
}
// Attempt comparison after type conversion
if reflect.DeepEqual(actual, expectedValue.Convert(actualType).Interface()) {
return true
}
}
// Last ditch effort
if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) {
return true
}
errFmt := "Expected: '%T(%#v)'\nActual: '%T(%#v)'\n(Should be equivalent)!"
return assert.Fail(t, errFmt, expected, expected, actual, actual)
}
示例3: validateTags
func (m *TaskCard) validateTags(formats strfmt.Registry) error {
if swag.IsZero(m.Tags) { // not required
return nil
}
iTagsSize := int64(len(m.Tags))
if err := validate.MaxItems("tags", "body", iTagsSize, 5); err != nil {
return err
}
if err := validate.UniqueItems("tags", "body", m.Tags); err != nil {
return err
}
for i := 0; i < len(m.Tags); i++ {
if err := validate.MinLength("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), 3); err != nil {
return err
}
if err := validate.Pattern("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), `\w[\w- ]+`); err != nil {
return err
}
}
return nil
}
示例4: validateTaxationStrategies
func (m *Organization) validateTaxationStrategies(formats strfmt.Registry) error {
if swag.IsZero(m.TaxationStrategies) { // not required
return nil
}
return nil
}
示例5: validateItems
func (m *ShipmentDto) validateItems(formats strfmt.Registry) error {
if swag.IsZero(m.Items) { // not required
return nil
}
return nil
}
示例6: validateReference
func (m *ItemDto) validateReference(formats strfmt.Registry) error {
if swag.IsZero(m.Reference) { // not required
return nil
}
return nil
}
示例7: validateTransitTimes
func (m *TransitTimeResponse) validateTransitTimes(formats strfmt.Registry) error {
if swag.IsZero(m.TransitTimes) { // not required
return nil
}
return nil
}
示例8: validateFixedTermDefinitions
func (m *ProductRatePlan) validateFixedTermDefinitions(formats strfmt.Registry) error {
if swag.IsZero(m.FixedTermDefinitions) { // not required
return nil
}
return nil
}
示例9: validateTags
func (m *Pet) validateTags(formats strfmt.Registry) error {
if swag.IsZero(m.Tags) { // not required
return nil
}
return nil
}
示例10: validateOpeningHour
func (m *DeliveryPointDto) validateOpeningHour(formats strfmt.Registry) error {
if swag.IsZero(m.OpeningHour) { // not required
return nil
}
return nil
}
示例11: validatePricingComponentValues
func (m *Subscription) validatePricingComponentValues(formats strfmt.Registry) error {
if swag.IsZero(m.PricingComponentValues) { // not required
return nil
}
return nil
}
示例12: validateCoordinate
func (m *ServicePointInformationDto) validateCoordinate(formats strfmt.Registry) error {
if swag.IsZero(m.Coordinate) { // not required
return nil
}
return nil
}
示例13: validatePaymentMethodSubscriptionLinks
func (m *Subscription) validatePaymentMethodSubscriptionLinks(formats strfmt.Registry) error {
if swag.IsZero(m.PaymentMethodSubscriptionLinks) { // not required
return nil
}
return nil
}
示例14: validateFixedTerms
func (m *Subscription) validateFixedTerms(formats strfmt.Registry) error {
if swag.IsZero(m.FixedTerms) { // not required
return nil
}
return nil
}
示例15: validateAddresses
func (m *UpdateProfileRequest) validateAddresses(formats strfmt.Registry) error {
if swag.IsZero(m.Addresses) { // not required
return nil
}
return nil
}