aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/bytes_example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bytes/bytes_example_test.go')
-rw-r--r--lib/bytes/bytes_example_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/bytes/bytes_example_test.go b/lib/bytes/bytes_example_test.go
index bd6b41ea..06b96146 100644
--- a/lib/bytes/bytes_example_test.go
+++ b/lib/bytes/bytes_example_test.go
@@ -105,6 +105,20 @@ func ExampleSkipAfterToken() {
// 12 true
}
+func ExampleSnippetByIndexes() {
+ s := []byte("// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.")
+ indexes := []int{3, 20, len(s) - 4}
+
+ snippets := SnippetByIndexes(s, indexes, 5)
+ for _, snip := range snippets {
+ fmt.Printf("%s\n", snip)
+ }
+ // Output:
+ // // Copyr
+ // 18, Shulha
+ // reserved.
+}
+
func ExampleTokenFind() {
line := []byte("// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.")
token := []byte("right")