diff options
| author | Shulhan <ms@kilabit.info> | 2025-01-22 21:33:10 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-01-22 21:34:16 +0700 |
| commit | 360cd7bdc721c2aa968e2f6888db1c7e36538ae2 (patch) | |
| tree | 08c6610214a4da1b54707231c235e81127deeae6 /lib/bytes/bytes_example_test.go | |
| parent | cdf43c8a97f6fbe7548aa45d3ce2680bdeb70e36 (diff) | |
| download | pakakeh.go-360cd7bdc721c2aa968e2f6888db1c7e36538ae2.tar.xz | |
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.
Diffstat (limited to 'lib/bytes/bytes_example_test.go')
| -rw-r--r-- | lib/bytes/bytes_example_test.go | 36 |
1 files changed, 0 insertions, 36 deletions
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`) |
