1// run 2 3// Copyright 2023 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7package main 8 9import ( 10 "reflect" 11 "runtime" 12) 13 14type T struct { 15 a, b int 16} 17 18func f(t *T) int { 19 if t != nil { 20 return t.b 21 } 22 return 0 23} 24 25func g(t *T) int { 26 return f(t) + 5 27} 28 29func main() { 30 x(f) 31 x(g) 32} 33func x(v any) { 34 println(runtime.FuncForPC(reflect.ValueOf(v).Pointer()).Name()) 35} 36