From 360cd7bdc721c2aa968e2f6888db1c7e36538ae2 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 22 Jan 2025 21:33:10 +0700 Subject: lib/bytes: replace Copy and Concat with standard library Since Go 1.20, the standard bytes package have the Copy function. Since Go 1.22, the standard slices package have the Concat function. --- lib/bytes/bytes_example_test.go | 36 ------------------------------------ 1 file changed, 36 deletions(-) (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 6615f36d..e8c18d9b 100644 --- a/lib/bytes/bytes_example_test.go +++ b/lib/bytes/bytes_example_test.go @@ -130,42 +130,6 @@ func ExampleAppendUint64() { // => []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xe8} } -func ExampleConcat() { - fmt.Printf("%s\n", libbytes.Concat()) - fmt.Printf("%s\n", libbytes.Concat([]byte{})) - fmt.Printf("%s\n", libbytes.Concat([]byte{}, []byte("B"))) - fmt.Printf("%s\n", libbytes.Concat("with []int:", []int{1, 2})) - fmt.Printf("%s\n", libbytes.Concat([]byte("bytes"), " and ", []byte("string"))) - fmt.Printf("%s\n", libbytes.Concat([]byte("A"), 1, []int{2}, []byte{}, []byte("C"))) - // Output: - // - // - // B - // with []int: - // bytes and string - // AC -} - -func ExampleCopy() { - // Copying empty slice. - org := []byte{} - cp := libbytes.Copy(org) - fmt.Printf("%d %q\n", len(cp), cp) - - org = []byte("slice of life") - tmp := org - cp = libbytes.Copy(org) - fmt.Printf("%d %q\n", len(cp), cp) - fmt.Printf("Original address == tmp address: %v\n", &org[0] == &tmp[0]) - fmt.Printf("Original address == copy address: %v\n", &org[0] == &cp[0]) - - // Output: - // 0 "" - // 13 "slice of life" - // Original address == tmp address: true - // Original address == copy address: false -} - func ExampleCutUntilToken() { text := []byte(`\\abc \def \deg`) -- cgit v1.3