Skip to content

Commit 6d89b38

Browse files
ianlancetaylorgopherbot
authored andcommitted
unsafe: clarify when String bytes can be modified
They can be modified when the string returned by String no longer exists. Fixes #68300 Change-Id: I526a068151f7aad1ab6827504b51a84e7399cafe Reviewed-on: https://go-review.googlesource.com/c/go/+/596955 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Commit-Queue: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 5565462 commit 6d89b38

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/unsafe/unsafe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func SliceData(slice []ArbitraryType) *ArbitraryType
260260
// a run-time panic occurs.
261261
//
262262
// Since Go strings are immutable, the bytes passed to String
263-
// must not be modified afterwards.
263+
// must not be modified as long as the returned string value exists.
264264
func String(ptr *byte, len IntegerType) string
265265

266266
// StringData returns a pointer to the underlying bytes of str.

0 commit comments

Comments
 (0)