From bde905af5b11e3e34bc1f5d4846d7767f7197236 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 21 May 2024 23:24:47 -0400 Subject: all: document legacy //go:linkname for modules with ≥20,000 dependents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For #67401. Change-Id: Icc10ede72547d8020c0ba45e89d954822a4b2455 Reviewed-on: https://go-review.googlesource.com/c/go/+/587218 Auto-Submit: Russ Cox Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI --- src/encoding/json/decode.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/encoding/json/decode.go') diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go index ce566f7955..efceecdf82 100644 --- a/src/encoding/json/decode.go +++ b/src/encoding/json/decode.go @@ -17,6 +17,7 @@ import ( "unicode" "unicode/utf16" "unicode/utf8" + _ "unsafe" // for linkname ) // Unmarshal parses the JSON-encoded data and stores the result @@ -1178,6 +1179,15 @@ func unquote(s []byte) (t string, ok bool) { return } +// unquoteBytes should be an internal detail, +// but widely used packages access it using linkname. +// Notable members of the hall of shame include: +// - github.com/bytedance/sonic +// +// Do not remove or change the type signature. +// See go.dev/issue/67401. +// +//go:linkname unquoteBytes func unquoteBytes(s []byte) (t []byte, ok bool) { if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' { return -- cgit v1.3-5-g9baa