runtime.Caller
runtime - The Go Programming Language
func Caller(skip int) (pc uintptr, file string, line int, ok bool)
Caller
はgoroutineのスタックから呼び出された関数のファイルと行数に関する情報をレポートします. 引数skip
は、スタックフレームをさかのぼる数で、0
が与えられた場合、runtime.Caller
を呼び出した自身のcallerを指します. (歴史的な理由により、runtime.Caller
とruntime.Callers
の引数skip
は意味が違うので注意です.) 返り値はそれぞれ該当する呼び出し元の、プログラムカウンタ、ファイル名、行数です. 第四返り値のok
は、これらの情報が取得できなかった場合にfalse
となります. *1
しらべた用語
しらべた英単語
*1:Caller reports file and line number information about function invocations on the calling goroutine's stack. The argument skip is the number of stack frames to ascend, with 0 identifying the caller of Caller. (For historical reasons the meaning of skip differs between Caller and Callers.) The return values report the program counter, file name, and line number within the file of the corresponding call. The boolean ok is false if it was not possible to recover the information.