code: func pkgIndex(file, funcName string) int {
  	// As of Go 1.6.2 there is no direct way to know the compile time GOPATH
  	// at runtime, but we can infer the number of path segments in the GOPATH.
  	// We note that runtime.Func.Name() returns the function name qualified by
  	// the import path, which does not include the GOPATH. Thus we can trim
  	// segments from the beginning of the file path until the number of path
  	// separators remaining is one more than the number of path separators in
  	// the function name. For example, given:
  	//
  	//    GOPATH     /home/user
  	//    file       /home/user/src/pkg/sub/file.go
  	//    fn.Name()  pkg/sub.Type.Method
  	//
  	// We want to produce:
  	//
  	//    file[:idx] == /home/user/src/
  	//    file[idx:] == pkg/sub/file.go
  	//
  	// From this we can easily see that fn.Name() has one less path separator
  	// than our desired result for file[idx:]. We count separators from the
  	// end of the file path until it finds two more than in the function name
  	// and then move one character forward to preserve the initial path
  	// segment without a leading separator.
  	const sep = "/"
  	i := len(file)
  	for n := strings.Count(funcName, sep) + 2; n > 0; n-- {
  		i = strings.LastIndex(file[:i], sep)
  		if i == -1 {
  			i = -len(sep)
  			break
  		}
  	}
  	// get back to 0 or trim the leading separator
  	return i + len(sep)
  }
docs: // pkgIndex returns the index that results in file[index:] being the path of
  // file relative to the compile time GOPATH, and file[:index] being the
  // $GOPATH/src/ portion of file. funcName must be the name of a function in
  // file as returned by runtime.Func.Name.