Is there a golang equivalent of PHP's magic __METHOD__
constant, to get current running function?
Asked
Active
Viewed 447 times
0

deceze
- 510,633
- 85
- 743
- 889

Louie Miranda
- 1,071
- 1
- 20
- 36
-
how about `__FUNCTION__` – jerry Nov 17 '18 at 04:25
2 Answers
0
I think you can use reflection for that.
This answer maybe will help you. Remember that Go is a little bit different from PHP.

cosmin_popescu
- 186
- 4
- 16
0
In PHP also, instead of using magic constants/functions, we have the alternative of using reflection.
In Go, we can get details about currently running function by using bellow packages which are essentially using the reflection and runtime to get the required details,
reflect
runtime
We have it already answered in How to get the name of a function in Go?