func ExampleCounter() { var c utils.Counter = 0 var ( BadInput = utils.InitFlag(&c, "BadInput") NotAuthorized = utils.InitFlag(&c, "NotAuthorized") InternalError = utils.InitFlag(&c, "InternalError") ) if !utils.Intersect(BadInput, NotAuthorized) && !utils.Intersect(NotAuthorized, InternalError) && !utils.Intersect(InternalError, BadInput) { fmt.Printf("None of them match!") } // Output: // None of them match! }
package atom import ( xmlutils "github.com/apognu/xml/utils" "github.com/jloup/utils" ) var ( MissingAttribute = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingAttribute") MissingDate = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingDate") MissingAuthor = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingAuthor") MissingId = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingId") MissingTitle = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingTitle") MissingSummary = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingSummary") MissingSelfLink = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingSelfLink") AttributeDuplicated = utils.InitFlag(&xmlutils.ErrorFlagCounter, "AttributeDuplicated") TitleDuplicated = utils.InitFlag(&xmlutils.ErrorFlagCounter, "TitleDuplicated") IdDuplicated = utils.InitFlag(&xmlutils.ErrorFlagCounter, "IdDuplicated") AttributeForbidden = utils.InitFlag(&xmlutils.ErrorFlagCounter, "AttributeForbidden") LeafElementHasChild = utils.InitFlag(&xmlutils.ErrorFlagCounter, "LeafElementHasChild") NotUniqueChild = utils.InitFlag(&xmlutils.ErrorFlagCounter, "NotUniqueChild") IsNotMIME = utils.InitFlag(&xmlutils.ErrorFlagCounter, "IsNotMIME") IriNotValid = utils.InitFlag(&xmlutils.ErrorFlagCounter, "IriNotValid") IriNotAbsolute = utils.InitFlag(&xmlutils.ErrorFlagCounter, "IriNotAbsolute") NotXMLMediaType = utils.InitFlag(&xmlutils.ErrorFlagCounter, "NotXMLMediaType") SourcedContentElementNotEmpty = utils.InitFlag(&xmlutils.ErrorFlagCounter, "SourcedContentElementNotEmpty") EntryWithIdAndDateDuplicated = utils.InitFlag(&xmlutils.ErrorFlagCounter, "EntryWithIdAndDateDuplicated") ContentTypeIsNotValid = utils.InitFlag(&xmlutils.ErrorFlagCounter, "ContentTypeIsNotValid")
package utils import ( "fmt" "github.com/jloup/utils" ) var ( ErrorFlagCounter utils.Counter = 0 XMLTokenError = utils.InitFlag(&ErrorFlagCounter, "XMLTokenError") XMLSyntaxError = utils.InitFlag(&ErrorFlagCounter, "XMLSyntaxError") XMLError = utils.Join("XMLError", XMLSyntaxError, XMLTokenError) IOError = utils.InitFlag(&ErrorFlagCounter, "IOError") ) type ParserError interface { utils.ErrorFlagged } type Error struct { flag utils.Flag msg string } func NewError(f utils.Flag, msg string) ParserError { return Error{flag: f, msg: msg} } func (s Error) Error() string { return fmt.Sprintf("[%s] %s", s.FlagString(), s.msg)
package rss import ( xmlutils "github.com/apognu/xml/utils" "github.com/jloup/utils" ) var ( LeafElementHasChild = utils.InitFlag(&xmlutils.ErrorFlagCounter, "LeafElementHasChild") MissingAttribute = utils.InitFlag(&xmlutils.ErrorFlagCounter, "MissingAttribute") AttributeDuplicated = utils.InitFlag(&xmlutils.ErrorFlagCounter, "AttributeDuplicated") XHTMLEncodeToStringError = utils.InitFlag(&xmlutils.ErrorFlagCounter, "XHTMLEncodeToStringError") CannotFlush = utils.InitFlag(&xmlutils.ErrorFlagCounter, "CannotFlush") DateFormat = utils.InitFlag(&xmlutils.ErrorFlagCounter, "DateFormat") IriNotValid = utils.InitFlag(&xmlutils.ErrorFlagCounter, "IriNotValid") )
package thr import ( xmlutils "github.com/apognu/xml/utils" "github.com/jloup/utils" ) var ( LinkNotReplies = utils.InitFlag(&xmlutils.ErrorFlagCounter, "LinkNotReplies") NotInLinkElement = utils.InitFlag(&xmlutils.ErrorFlagCounter, "NotInLinkElement") )
//Package feed implements a flexible RSS/Atom parser package feed import ( "io" "github.com/apognu/xml/feed/extension" xmlutils "github.com/apognu/xml/utils" "github.com/jloup/utils" ) var NoFeedFound = utils.InitFlag(&xmlutils.ErrorFlagCounter, "NoFeedFound") // ParseOptions is passed to Parse functions to customize their behaviors type ParseOptions struct { ExtensionManager extension.Manager ErrorFlags xmlutils.FlagChecker } // DefaultOptions set options in order to have: // - no specification checking // - no extension var DefaultOptions ParseOptions func init() { errorFlags := xmlutils.NewErrorChecker(xmlutils.DisableAllError) DefaultOptions = ParseOptions{ extension.Manager{}, &errorFlags, } }