From f31dc2563c9d264a81ae3dd74f6c6a6a3db629c8 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 4 Jun 2023 00:35:27 +0700 Subject: lib/bytes: add function RemoveSpaces Unlike TrimSpaces, which only remove spaces on beginning and end, RemoveSpaces remove all spaces including in between characters. --- lib/bytes/bytes_example_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/bytes/bytes_example_test.go') diff --git a/lib/bytes/bytes_example_test.go b/lib/bytes/bytes_example_test.go index 44889909..84796302 100644 --- a/lib/bytes/bytes_example_test.go +++ b/lib/bytes/bytes_example_test.go @@ -340,6 +340,18 @@ func ExampleReadUint32() { // 4043440900 } +func ExampleRemoveSpaces() { + var ( + in = []byte(" a\nb\tc d\r") + out = libbytes.RemoveSpaces(in) + ) + + fmt.Printf("%s\n", out) + + // Output: + // abcd +} + func ExampleSkipAfterToken() { text := []byte(`abc \def ghi`) -- cgit v1.3-6-g1900