1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:50:05 -07:00
go/test/reflectmethod7.go
Cuong Manh Le 283d8a3d53 all: use reflect.{Pointer,PointerTo}
Updates #47651
Updates #48665

Change-Id: I69a87b45a5cad7a07fbd855040cd9935cf874554
Reviewed-on: https://go-review.googlesource.com/c/go/+/358454
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-26 14:24:17 +00:00

25 lines
421 B
Go

// run
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// See issue 44207.
package main
import "reflect"
type S int
func (s S) M() {}
func main() {
t := reflect.TypeOf(S(0))
fn, ok := reflect.PointerTo(t).MethodByName("M")
if !ok {
panic("FAIL")
}
fn.Func.Call([]reflect.Value{reflect.New(t)})
}