當前位置: 首頁>>代碼示例>>Golang>>正文


Golang utils.ErrorAggregator類代碼示例

本文整理匯總了Golang中github.com/jloup/utils.ErrorAggregator的典型用法代碼示例。如果您正苦於以下問題:Golang ErrorAggregator類的具體用法?Golang ErrorAggregator怎麽用?Golang ErrorAggregator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ErrorAggregator類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: validateLinks

func (f *Feed) validateLinks(err *utils.ErrorAggregator) {
	combinations := make([]string, 0)
	hasSelf := false

	for _, link := range f.Links {
		if link.Rel.Value == "alternate" {
			s := link.Type.Value + link.HrefLang.Value
			unique := true

			for _, comb := range combinations {
				if s == comb {
					err.NewError(xmlutils.NewError(LinkAlternateDuplicated, fmt.Sprintf("Alternate Link duplicated: hreflang '%s' type '%s'", link.HrefLang.Value, link.Type.Value)))
					unique = false
				}
			}

			if unique {
				combinations = append(combinations, s)
			}
		} else if link.Rel.Value == "self" {
			hasSelf = true
		}
	}

	if !hasSelf {
		err.NewError(xmlutils.NewError(MissingSelfLink, "Feed must have a link with rel attribute set to 'self'"))
	}
}
開發者ID:apognu,項目名稱:xml,代碼行數:28,代碼來源:feed.go

示例2: validateLinks

func (e *Entry) validateLinks(err *utils.ErrorAggregator) {
	combinations := make([]string, 0)
	hasAlternateRel := false

	for _, link := range e.Links {
		if link.Rel.Value == "alternate" {
			hasAlternateRel = true
			s := link.Type.Value + link.HrefLang.Value
			unique := true

			for _, comb := range combinations {
				if s == comb {
					err.NewError(xmlutils.NewError(LinkAlternateDuplicated, fmt.Sprintf("Alternate Link duplicated: hreflang '%s' type '%s'", link.HrefLang.Value, link.Type.Value)))
					unique = false
				}
			}

			if unique {
				combinations = append(combinations, s)
			}
		}
	}

	if e.Occurences.Count("content") == 0 && !hasAlternateRel {
		err.NewError(xmlutils.NewError(NoContentOrAlternateLink, "Entry should have either a Content element or a Link with alternate type"))
	}
}
開發者ID:apognu,項目名稱:xml,代碼行數:27,代碼來源:entry.go

示例3: Validate

func (s *Store) Validate(errorAgg *utils.ErrorAggregator) {
	for _, store := range s.stores {
		for _, ext := range store.extensions {
			if _, ok := ext.(Attr); ok {
				if err := ext.Validate(); err != nil {
					errorAgg.NewError(err)
				}
			}
		}
	}
}
開發者ID:apognu,項目名稱:xml,代碼行數:11,代碼來源:store.go

示例4: validateAuthors

func (f *Feed) validateAuthors(err *utils.ErrorAggregator) {
	if len(f.Authors) > 0 {
		return
	}

	count := 0
	for _, entry := range f.Entries {

		if !entry.hasAuthor() {
			count += 1
		}
	}

	if count > 0 || len(f.Entries) == 0 {
		err.NewError(xmlutils.NewError(MissingAuthor, fmt.Sprintf("%v entry(ies) are missing author reference", count)))
	}
}
開發者ID:apognu,項目名稱:xml,代碼行數:17,代碼來源:feed.go

示例5: validateEntries

func (f *Feed) validateEntries(err *utils.ErrorAggregator) {
	combinations := make([]string, 0)

	for _, entry := range f.Entries {
		s := entry.Id.Content.Value + entry.Updated.Time.String()
		unique := true
		for _, comb := range combinations {

			if s == comb {
				err.NewError(xmlutils.NewError(EntryWithIdAndDateDuplicated, fmt.Sprintf("Entries are duplicated: id '%s' updated '%s'", entry.Id.Content.Value, entry.Updated.Time.String())))
				unique = false
			}
		}

		if unique {
			combinations = append(combinations, s)
		}
	}
}
開發者ID:apognu,項目名稱:xml,代碼行數:19,代碼來源:feed.go

示例6: validateLinks

func (s *Source) validateLinks(err *utils.ErrorAggregator) {
	combinations := make([]string, 0)

	for _, link := range s.Links {
		if link.Rel.Value == "alternate" {
			s := link.Type.Value + link.HrefLang.Value
			unique := true

			for _, comb := range combinations {
				if s == comb {
					err.NewError(xmlutils.NewError(LinkAlternateDuplicated, fmt.Sprintf("Alternate Link duplicated: hreflang '%s' type '%s'", link.HrefLang.Value, link.Type.Value)))
					unique = false
				}
			}

			if unique {
				combinations = append(combinations, s)
			}
		}
	}

}
開發者ID:apognu,項目名稱:xml,代碼行數:22,代碼來源:source.go

示例7: ValidateElement

func ValidateElement(parentName string, el Valider, agg *utils.ErrorAggregator) {
	if err := el.Validate(); err != nil {
		agg.NewError(NewError(err.Flag(), fmt.Sprintf("%s's %s", parentName, err.Msg())))
	}
}
開發者ID:apognu,項目名稱:xml,代碼行數:5,代碼來源:validator.go

示例8: validateAuthors

func (e *Entry) validateAuthors(err *utils.ErrorAggregator) {
	if e.Parent == nil && !e.hasAuthor() {
		err.NewError(xmlutils.NewError(MissingAuthor, "entry should contain at least one author"))
	}

}
開發者ID:apognu,項目名稱:xml,代碼行數:6,代碼來源:entry.go


注:本文中的github.com/jloup/utils.ErrorAggregator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。