]> Cypherpunks repositories - gostls13.git/commitdiff
doc/go1.22: document reflect.TypeFor
authorMauri de Souza Meneguzzo <mauri870@gmail.com>
Tue, 12 Dec 2023 21:32:10 +0000 (21:32 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 13 Dec 2023 00:46:41 +0000 (00:46 +0000)
Change-Id: I122a3422f541f66d9f6e644a9f287f0e5a5729d2
GitHub-Last-Rev: 1d9fe39d0c1221d7179476383f3d503e45daa051
GitHub-Pull-Request: golang/go#64688
Reviewed-on: https://go-review.googlesource.com/c/go/+/549295
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
doc/go1.22.html

index 9cea5ba8c2b14650570bf31c9c5d81d82970acb9..1ac0e7e6ee1d584403afa6663c6554c56e96da78 100644 (file)
@@ -728,8 +728,13 @@ defer func() {
       in favor of <a href="/pkg/reflect/#PointerTo"><code>PointerTo</code></a>.
     </p>
 
-    <p><!-- https://go.dev/issue/60088 -->
-      TODO: <a href="https://go.dev/issue/60088">https://go.dev/issue/60088</a>: reflect: add TypeFor
+    <p><!-- https://go.dev/issue/60088, CL 513478 -->
+      The new function <a href="/pkg/reflect/#TypeFor"><code>TypeFor</code></a>
+      returns the <a href="/pkg/reflect/#Type"><code>Type</code></a> that represents
+      the type argument T.
+      Previously, to get the <code>reflect.Type</code> value for a type, one had to use
+      <code>reflect.TypeOf((*T)(nil)).Elem()</code>.
+      This may now be written as <code>reflect.TypeFor[T]()</code>.
     </p>
   </dd>
 </dl><!-- reflect -->