本文整理汇总了Golang中strings.Reader.UnreadByte方法的典型用法代码示例。如果您正苦于以下问题:Golang Reader.UnreadByte方法的具体用法?Golang Reader.UnreadByte怎么用?Golang Reader.UnreadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strings.Reader
的用法示例。
在下文中一共展示了Reader.UnreadByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: entryCompleted
// Looks ahead to see if the next character completes the entry. Does not read
// any characters from the reader.
func entryCompleted(r *strings.Reader) bool {
if r.Len() > 0 {
b, _ := r.ReadByte()
r.UnreadByte()
return b == lineSeparator || b == entrySeparator
}
return true
}
示例2: consume
// Attempts to consume the wanted character from the reader. Returns true if
// character was read successfully, false otherwise. If the character could
// not be read, then no characters are consumed from the reader.
func consume(r *strings.Reader, wanted byte) bool {
if r.Len() > 0 {
b, _ := r.ReadByte()
if b == wanted {
return true
}
r.UnreadByte()
}
return false
}