0

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

deceze
  • 510,633
  • 85
  • 743
  • 889
Louie Miranda
  • 1,071
  • 1
  • 20
  • 36

2 Answers2

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?

Community
  • 1
  • 1
Jeevan
  • 309
  • 1
  • 6