aboutsummaryrefslogtreecommitdiff
path: root/src/reflect/type.go
diff options
context:
space:
mode:
authorIlya Priven <ilya.konstantinov@gmail.com>2025-03-15 22:58:18 +0000
committerGopher Robot <gobot@golang.org>2025-03-17 13:09:29 -0700
commite41ec30c8a7369872d22113b022b2a31757ff72b (patch)
treed62f85a17a2f0e690e79b77cd96022f1020475f4 /src/reflect/type.go
parentbceade5ef8ab6d28ad363cd7ca60a9be89990a00 (diff)
downloadgo-e41ec30c8a7369872d22113b022b2a31757ff72b.tar.xz
reflect: document Method(ByName) w.r.t dead code elimination
The behavior is described in src/cmd/link/internal/ld/deadcode.go but is not otherwise documented. Since the usage of those functions could have significant caveats (longer builds, larger binaries), we are informing the user. Change-Id: I87571dd14aa16d7aac59fe45dfc52cb7c5b956c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/658255 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/reflect/type.go')
-rw-r--r--src/reflect/type.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go
index b6fc99a934..0004cab985 100644
--- a/src/reflect/type.go
+++ b/src/reflect/type.go
@@ -59,6 +59,9 @@ type Type interface {
// method signature, without a receiver, and the Func field is nil.
//
// Methods are sorted in lexicographic order.
+ //
+ // Calling this method will force the linker to retain all exported methods in all packages.
+ // This may make the executable binary larger but will not affect execution time.
Method(int) Method
// MethodByName returns the method with that name in the type's
@@ -69,6 +72,10 @@ type Type interface {
//
// For an interface type, the returned Method's Type field gives the
// method signature, without a receiver, and the Func field is nil.
+ //
+ // Calling this method will cause the linker to retain all methods with this name in all packages.
+ // If the linker can't determine the name, it will retain all exported methods.
+ // This may make the executable binary larger but will not affect execution time.
MethodByName(string) (Method, bool)
// NumMethod returns the number of methods accessible using Method.