Skip to content

Commit bc2e961

Browse files
CAFxXgopherbot
authored andcommitted
reflect: deprecate (Slice|String)Header
As discussed in CL 401434 there are substantial misuses of these in the wild, and they are a potential source of unsafety even for code that does not use them directly. We should either keep them as-is and document when/how they can be used safely, or deprecate them so that uses will eventually die out. After some discussion, it was decided to deprecate them outright. Since the docs already mentioned that they may be unstable across releases, it should be possible to get rid of them completely later on. Change-Id: I3b75819409177b5a286c1e9861a2edb6fd1301b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/401434 Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 5f2fdbe commit bc2e961

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

doc/go1.19.html

+10
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
166166
</dd>
167167
</dl> <!-- os/exec -->
168168

169+
<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
170+
<dd>
171+
<p><!-- CL 401434 -->
172+
<a href="/pkg/strconv/#reflect.SliceHeader"></a><code>reflect.SliceHeader</code>
173+
and <a href="/pkg/strconv/#reflect.StringHeader"></a><code>reflect.StringHeader</code>
174+
are now deprecated, and their use should be avoided.
175+
</p>
176+
</dd>
177+
</dl><!-- reflect -->
178+
169179
<dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
170180
<dd>
171181
<p><!-- https://go.dev/issue/51461 -->

src/reflect/value.go

+6
Original file line numberDiff line numberDiff line change
@@ -2660,6 +2660,9 @@ func (v Value) UnsafePointer() unsafe.Pointer {
26602660
// Moreover, the Data field is not sufficient to guarantee the data
26612661
// it references will not be garbage collected, so programs must keep
26622662
// a separate, correctly typed pointer to the underlying data.
2663+
//
2664+
// Deprecated: this type should not be used, it exists only for
2665+
// backward compatibility.
26632666
type StringHeader struct {
26642667
Data uintptr
26652668
Len int
@@ -2671,6 +2674,9 @@ type StringHeader struct {
26712674
// Moreover, the Data field is not sufficient to guarantee the data
26722675
// it references will not be garbage collected, so programs must keep
26732676
// a separate, correctly typed pointer to the underlying data.
2677+
//
2678+
// Deprecated: this type should not be used, it exists only for
2679+
// backward compatibility.
26742680
type SliceHeader struct {
26752681
Data uintptr
26762682
Len int

0 commit comments

Comments
 (0)