diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/apparentlymart/go-textseg/textseg/all_tokens.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/apparentlymart/go-textseg/textseg/all_tokens.go')
-rw-r--r-- | vendor/github.com/apparentlymart/go-textseg/textseg/all_tokens.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/github.com/apparentlymart/go-textseg/textseg/all_tokens.go b/vendor/github.com/apparentlymart/go-textseg/textseg/all_tokens.go new file mode 100644 index 0000000..5752e9e --- /dev/null +++ b/vendor/github.com/apparentlymart/go-textseg/textseg/all_tokens.go | |||
@@ -0,0 +1,30 @@ | |||
1 | package textseg | ||
2 | |||
3 | import ( | ||
4 | "bufio" | ||
5 | "bytes" | ||
6 | ) | ||
7 | |||
8 | // AllTokens is a utility that uses a bufio.SplitFunc to produce a slice of | ||
9 | // all of the recognized tokens in the given buffer. | ||
10 | func AllTokens(buf []byte, splitFunc bufio.SplitFunc) ([][]byte, error) { | ||
11 | scanner := bufio.NewScanner(bytes.NewReader(buf)) | ||
12 | scanner.Split(splitFunc) | ||
13 | var ret [][]byte | ||
14 | for scanner.Scan() { | ||
15 | ret = append(ret, scanner.Bytes()) | ||
16 | } | ||
17 | return ret, scanner.Err() | ||
18 | } | ||
19 | |||
20 | // TokenCount is a utility that uses a bufio.SplitFunc to count the number of | ||
21 | // recognized tokens in the given buffer. | ||
22 | func TokenCount(buf []byte, splitFunc bufio.SplitFunc) (int, error) { | ||
23 | scanner := bufio.NewScanner(bytes.NewReader(buf)) | ||
24 | scanner.Split(splitFunc) | ||
25 | var ret int | ||
26 | for scanner.Scan() { | ||
27 | ret++ | ||
28 | } | ||
29 | return ret, scanner.Err() | ||
30 | } | ||