MCPcopy Create free account
hub / github.com/golang/appengine / findMainPath

Function findMainPath

internal/main_vm.go:39–54  ·  view source on GitHub ↗

Find the path to package main by looking at the root Caller.

()

Source from the content-addressed store, hash-verified

37
38// Find the path to package main by looking at the root Caller.
39func findMainPath() string {
40 pc := make([]uintptr, 100)
41 n := runtime.Callers(2, pc)
42 frames := runtime.CallersFrames(pc[:n])
43 for {
44 frame, more := frames.Next()
45 // Tests won't have package main, instead they have testing.tRunner
46 if frame.Function == "main.main" || frame.Function == "testing.tRunner" {
47 return frame.File
48 }
49 if !more {
50 break
51 }
52 }
53 return ""
54}
55
56func installHealthChecker(mux *http.ServeMux) {
57 // If no health check handler has been installed by this point, add a trivial one.

Callers 2

MainFunction · 0.70
TestFindMainPathFunction · 0.70

Calls 1

NextMethod · 0.45

Tested by 1

TestFindMainPathFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…