scan

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EqualPair 扫描 K=V这类形式的Pair字串
	EqualPair = NewPair('=',
		func(r rune) bool {
			return unicode.IsSpace(r) || r == '"'
		})

	// ColonPair 扫描 K:V 这类形式的Pair字串
	ColonPair = NewPair(':',
		func(r rune) bool {
			return unicode.IsSpace(r) || r == '"'
		})
)

预定义Pair扫描对象

View Source
var (
	// 逗号分割
	Comma = NewScanner(',', unicode.IsSpace)
	// 分号分割
	Semicolon = NewScanner(';', unicode.IsSpace)
	// 空格分割
	Space = NewScanner(' ', nil)
	// 行分割
	Line = NewScanner('\n', unicode.IsSpace)
)

扫描器

Functions

This section is empty.

Types

type Pair

type Pair struct {
	// contains filtered or unexported fields
}

Pair 从字串扫描Key Value 值

func NewPair

func NewPair(delim rune, trimFunc func(r rune) bool) Pair

NewPair 新建 Pair 扫描器

func (Pair) Scan

func (p Pair) Scan(s string) (key, value string, found bool)

Scan 提取 K V

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner 扫描器

func NewScanner

func NewScanner(delim rune, trimFunc func(r rune) bool) Scanner

NewScanner 创建扫描器

func (Scanner) Scan

func (s Scanner) Scan(str string) (advance, token string, continueScan bool)

Scan 扫描字串

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL