You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
312 B
23 lines
312 B
3 years ago
|
package entry
|
||
|
|
||
|
import (
|
||
|
"path/filepath"
|
||
|
"runtime"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func Caller(depth int, full bool) string {
|
||
|
const offset = 4
|
||
|
_, file, line, ok := runtime.Caller(depth + offset)
|
||
|
|
||
|
if !ok {
|
||
|
file, line = "???", 0
|
||
|
}
|
||
|
|
||
|
if !full && ok {
|
||
|
file = filepath.Base(file)
|
||
|
}
|
||
|
|
||
|
return file + ":" + strconv.Itoa(line)
|
||
|
}
|