golang上的PHP __METHOD__的等价物[复制]

This question already has an answer here:

Is there a golang equivalent of PHP's magic __METHOD__ constant, to get current running function?

</div>

I think you can use reflection for that.

This answer maybe will help you. Remember that Go is a little bit different from PHP.

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?