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 14func f(n int) int { 15 return n % 2 16} 17 18func g(n int) int { 19 return f(n) 20} 21 22func name(fn any) (res string) { 23 return runtime.FuncForPC(uintptr(reflect.ValueOf(fn).Pointer())).Name() 24} 25 26func main() { 27 println(name(f)) 28 println(name(g)) 29} 30