aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorSean Liao <sean@liao.dev>2025-03-21 23:23:50 +0000
committerSean Liao <sean@liao.dev>2025-10-31 07:35:59 -0700
commit99b724f4542f4d9fb4a2ceacbbd2a6d9367dc0f6 (patch)
tree3e43e1426fd56685fe280274e869a20315b15676 /src/cmd
parent27937289dc9fccf1f5513475145799087f39b964 (diff)
downloadgo-99b724f4542f4d9fb4a2ceacbbd2a6d9367dc0f6.tar.xz
cmd/go: document purego convention
Fixes #23172 Change-Id: I854e399471dfa22e62fbdec9719e561c4501e5ac Reviewed-on: https://go-review.googlesource.com/c/go/+/660136 Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/go/alldocs.go6
-rw-r--r--src/cmd/go/internal/help/helpdoc.go6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 46bca7480b..1029d1e8c2 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -2190,6 +2190,12 @@
// building the package for Windows; similarly, math_386.s will be included
// only when building the package for 32-bit x86.
//
+// By convention, packages with assembly implementations may provide a go-only
+// version under the "purego" build constraint. This does not limit the use of
+// cgo (use the "cgo" build constraint) or unsafe. For example:
+//
+// //go:build purego
+//
// Go versions 1.16 and earlier used a different syntax for build constraints,
// with a "// +build" prefix. The gofmt command will add an equivalent //go:build
// constraint when encountering the older syntax.
diff --git a/src/cmd/go/internal/help/helpdoc.go b/src/cmd/go/internal/help/helpdoc.go
index ab04ce001c..1d3ffefc97 100644
--- a/src/cmd/go/internal/help/helpdoc.go
+++ b/src/cmd/go/internal/help/helpdoc.go
@@ -1009,6 +1009,12 @@ Naming a file dns_windows.go will cause it to be included only when
building the package for Windows; similarly, math_386.s will be included
only when building the package for 32-bit x86.
+By convention, packages with assembly implementations may provide a go-only
+version under the "purego" build constraint. This does not limit the use of
+cgo (use the "cgo" build constraint) or unsafe. For example:
+
+ //go:build purego
+
Go versions 1.16 and earlier used a different syntax for build constraints,
with a "// +build" prefix. The gofmt command will add an equivalent //go:build
constraint when encountering the older syntax.