Is there a way to get the source code file name and line number in Go?

In C / C ++, you can use __FILE__and __LINE__to access the current file and line number.

Is there something similar?

+3
source share
1 answer

In fact, it does:

http://golang.org/pkg/runtime/#Caller

runtime.Caller can also be used to get the file name / number of the calling function.

+6
source

Source: https://habr.com/ru/post/1791008/


All Articles