(i int)
| 101 | } |
| 102 | |
| 103 | func stackCallerModule(i int) string { |
| 104 | buf := stackBuf.Get().([]byte) |
| 105 | defer stackBuf.Put(buf) |
| 106 | |
| 107 | buf = buf[:runtime.Stack(buf, false)] |
| 108 | str := unsafe.String(unsafe.SliceData(buf), len(buf)) |
| 109 | |
| 110 | lines := strings.Split(str, "\n")[1:] |
| 111 | |
| 112 | i = int(math.RoundToEven(float64(i))) + 1 |
| 113 | line := lines[i] |
| 114 | |
| 115 | sp := strings.Split(line, "/") |
| 116 | if len(sp) == 0 { |
| 117 | return "" |
| 118 | } |
| 119 | i = strings.Index(sp[len(sp)-1], ".") |
| 120 | if i != -1 { |
| 121 | sp[len(sp)-1] = sp[len(sp)-1][:i] |
| 122 | } |
| 123 | |
| 124 | if i := strings.Index(sp[0], "."); i != -1 { |
| 125 | sp = sp[2:] |
| 126 | } |
| 127 | |
| 128 | modName := sp[0] |
| 129 | pkgName := sp[len(sp)-1] |
| 130 | |
| 131 | if modName == "main" { |
| 132 | modName = mainModuleName |
| 133 | } |
| 134 | |
| 135 | return modName + "::" + pkgName |
| 136 | } |
| 137 | |
| 138 | /* |
| 139 | Println prints the content prefixed and suffixed with a carriage return with an endline in the end. |
no test coverage detected