Caller filename
- caller
- runtime
package main
import (
"fmt"
"runtime"
)
func main() {
_, file, _, _ := runtime.Caller(0)
fmt.Println(file)
}
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
package main
import (
"fmt"
"runtime"
)
func main() {
_, file, _, _ := runtime.Caller(0)
fmt.Println(file)
}