Init initializes RemoteSrcPath, SrcName, DirName and Line. For test main, it initializes Location only with Stdlib. It does its best educated guess for ImportPath.
(srcPath string, line int)
| 381 | // |
| 382 | // It does its best educated guess for ImportPath. |
| 383 | func (c *Call) init(srcPath string, line int) { |
| 384 | c.Line = line |
| 385 | if srcPath != "" { |
| 386 | c.RemoteSrcPath = srcPath |
| 387 | if i := strings.LastIndexByte(c.RemoteSrcPath, '/'); i != -1 { |
| 388 | c.SrcName = c.RemoteSrcPath[i+1:] |
| 389 | if i = strings.LastIndexByte(c.RemoteSrcPath[:i], '/'); i != -1 { |
| 390 | c.DirSrc = c.RemoteSrcPath[i+1:] |
| 391 | } |
| 392 | } |
| 393 | if c.DirSrc == testMainSrc { |
| 394 | // Consider _test/_testmain.go as stdlib since it's injected by "go test". |
| 395 | c.Location = Stdlib |
| 396 | } |
| 397 | } |
| 398 | c.ImportPath = c.Func.ImportPath |
| 399 | } |
| 400 | |
| 401 | const testMainSrc = "_test" + string(os.PathSeparator) + "_testmain.go" |
| 402 |