Improved code quality

This commit is contained in:
Eduard Urbach 2023-08-31 17:03:52 +02:00
parent 3ff7ac9a08
commit acec282709
Signed by: eduard
GPG key ID: 49226B848C78F6C8
16 changed files with 128 additions and 69 deletions

26
file.go
View file

@ -1,26 +0,0 @@
package assert
import (
"runtime/debug"
"strings"
)
// file returns the first line containing "_test.go" in the debug stack.
func file() string {
stack := string(debug.Stack())
lines := strings.Split(stack, "\n")
for _, line := range lines {
if strings.Contains(line, "_test.go") {
space := strings.LastIndex(line, " ")
if space != -1 {
line = line[:space]
}
return strings.TrimSpace(line)
}
}
return ""
}