diff --git a/errors.go b/errors.go index b0730e0..7152e3a 100644 --- a/errors.go +++ b/errors.go @@ -6,5 +6,4 @@ import ( var ( ErrNothingToUnread = adverr.NewErrTmpl("ErrNothingToUnread", "Unreading failed because there wasn't any Read yet") - ErrNoMatchFound = adverr.NewErrTmpl("ErrNoMatchFound", "no match found") ) diff --git a/reader.go b/reader.go index 628cc79..d8ece28 100644 --- a/reader.go +++ b/reader.go @@ -233,21 +233,21 @@ func (r *Reader) ExpectString(str string) (bool, error) { // ExpectOneOfString calls ExpectString for each string successively // and returns the string which first matched. +// The boolean value is true if any string was found. // The returned string will not be unread. -// If no string matches, ErrNoMatchFound is returned -func (r *Reader) ExpectOneOfString(str ...string) (string, error) { +func (r *Reader) ExpectOneOfString(str ...string) (string, bool, error) { for _, s := range str { ok, err := r.ExpectString(s) if err != nil { - return "", err + return "", false, err } if ok { - return s, nil + return s, true, nil } } - return "", ErrNoMatchFound.New() + return "", false, nil } // Commit clears the internal buffer and therefore removes all data which were already read.