aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/bytes_example_test.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2019-09-24 22:22:02 +0700
committerShulhan <m.shulhan@gmail.com>2019-09-24 22:38:39 +0700
commit7eacd3ade3ecc83ee59ca8ce14cb60c2082096a3 (patch)
tree431c01263c1b70a5205d7952d2da0e6ea1b45a37 /lib/bytes/bytes_example_test.go
parent7474d7ac41d49af9e15a5c21de99a3eaea5f68b4 (diff)
downloadpakakeh.go-7eacd3ade3ecc83ee59ca8ce14cb60c2082096a3.tar.xz
bytes: add function get all indexes of token in string
Diffstat (limited to 'lib/bytes/bytes_example_test.go')
-rw-r--r--lib/bytes/bytes_example_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/bytes/bytes_example_test.go b/lib/bytes/bytes_example_test.go
index 141d7f17..bd6b41ea 100644
--- a/lib/bytes/bytes_example_test.go
+++ b/lib/bytes/bytes_example_test.go
@@ -54,6 +54,16 @@ func ExampleEncloseToken() {
// '// Copyright 2016-2018 \"_Shulhan <ms@kilabit.info>\"_. All rights reserved.' true
}
+func ExampleIndexes() {
+ s := []byte("moo moomoo")
+ token := []byte("moo")
+
+ idxs := Indexes(s, token)
+ fmt.Println(idxs)
+ // Output:
+ // [0 4 7]
+}
+
func ExampleIsTokenAt() {
line := []byte("Hello, world")
token := []byte("world")