aboutsummaryrefslogtreecommitdiff
path: root/lib/parser/parser_example_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-03-11 11:38:31 +0700
committerShulhan <ms@kilabit.info>2023-03-12 11:34:23 +0700
commit61786b2a6c1a7c9d11ee18cab4a804afdce9ffa5 (patch)
tree391a1cdaba298272fa633954b9bae5f039de9634 /lib/parser/parser_example_test.go
parentd759b751c0b055b9cc592155e48280740558ad24 (diff)
downloadpakakeh.go-61786b2a6c1a7c9d11ee18cab4a804afdce9ffa5.tar.xz
lib/parser: add method TokenTrimSpace
The TokenTrimSpace read the next token until one of the delimiter found, with leading and trailing spaces are ignored.
Diffstat (limited to 'lib/parser/parser_example_test.go')
-rw-r--r--lib/parser/parser_example_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/parser/parser_example_test.go b/lib/parser/parser_example_test.go
index e5419353..b4c4c9f5 100644
--- a/lib/parser/parser_example_test.go
+++ b/lib/parser/parser_example_test.go
@@ -27,3 +27,27 @@ func ExampleNew() {
// "key" '='
// "value" '\x00'
}
+
+func ExampleParser_TokenTrimSpace() {
+ var (
+ content = " 1 , \r\t\f, 2 , 3 , 4 , "
+ p = New(content, `,`)
+
+ tok string
+ r rune
+ )
+ for {
+ tok, r = p.TokenTrimSpace()
+ fmt.Printf("%q\n", tok)
+ if r == 0 {
+ break
+ }
+ }
+ // Output:
+ // "1"
+ // ""
+ // "2"
+ // "3"
+ // "4"
+ // ""
+}