In C/C, you can use __FILE__
and __LINE__
to access the current File and line numbers.
Does Go offer something similar?
Indeed:
https://www.php.cn/link/c0e0b7080b94f208328b48cbea738d86
runtime.Caller
can also be used to get the file name/line number of the calling function.
The above is the detailed content of Is there a way in Go to get the source code filename and line number?. For more information, please follow other related articles on the PHP Chinese website!