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
315 B

3 years ago
package entry
import (
"path/filepath"
"runtime"
"strconv"
)
func Caller(depth int, full bool) string {
const offset = 3
3 years ago
_, file, line, has := runtime.Caller(depth + offset)
3 years ago
3 years ago
if !has {
3 years ago
file, line = "???", 0
}
3 years ago
if !full && has {
3 years ago
file = filepath.Base(file)
}
return file + ":" + strconv.Itoa(line)
}