aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/bytes_example_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-04-05 00:16:25 +0700
committerShulhan <ms@kilabit.info>2023-04-05 00:21:03 +0700
commit3c849a75ca157d79d90f23e88221c30b09d59a65 (patch)
tree52b7bedadb1198f294528bc187b1f6615a4a6a28 /lib/bytes/bytes_example_test.go
parent56157387c1771d5afceee5638e5252843b239f79 (diff)
downloadpakakeh.go-3c849a75ca157d79d90f23e88221c30b09d59a65.tar.xz
lib/bytes: add function TrimNull
The TrimNull function remove 0 value ("\0" or NULL in C) at leading and trailing of input.
Diffstat (limited to 'lib/bytes/bytes_example_test.go')
-rw-r--r--lib/bytes/bytes_example_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/bytes/bytes_example_test.go b/lib/bytes/bytes_example_test.go
index 1b68fd42..3d6a11b5 100644
--- a/lib/bytes/bytes_example_test.go
+++ b/lib/bytes/bytes_example_test.go
@@ -386,6 +386,14 @@ func ExampleTokenFind() {
// 64
}
+func ExampleTrimNull() {
+ var in = []byte{0, 'H', 'e', 'l', 'l', 'o', 0, 0}
+
+ in = TrimNull(in)
+ fmt.Printf(`%s`, in)
+ // Output: Hello
+}
+
func ExampleWordIndexes() {
text := []byte("moo moomoo moo")