From 5efb4239c6627e81e82b88377b9eb947f7f253d4 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 18 Dec 2024 14:15:48 -0800 Subject: [PATCH] spec: document that string conversions don't guarantee result slice capacity Fixes #24163. Change-Id: If389c4abf3b9b6e4eba6f31c3c12779329456df6 Reviewed-on: https://go-review.googlesource.com/c/go/+/637655 Reviewed-by: Robert Griesemer Reviewed-by: Ian Lance Taylor Auto-Submit: Robert Griesemer TryBot-Bypass: Robert Griesemer --- doc/go_spec.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/go_spec.html b/doc/go_spec.html index 8ff178e281..c6c4b30b04 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -5686,6 +5686,8 @@ myString([]myRune{0x1f30e}) // "\U0001f30e" == "🌎"
  • Converting a value of a string type to a slice of bytes type yields a non-nil slice whose successive elements are the bytes of the string. +The capacity of the resulting slice is +implementation-specific and may be larger than the slice length.
     []byte("hellø")             // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
    @@ -5701,6 +5703,8 @@ bytes("hellø")              // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
     
  • Converting a value of a string type to a slice of runes type yields a slice containing the individual Unicode code points of the string. +The capacity of the resulting slice is +implementation-specific and may be larger than the slice length.
     []rune(myString("白鵬翔"))   // []rune{0x767d, 0x9d6c, 0x7fd4}
    -- 
    2.48.1