Improved code quality
This commit is contained in:
parent
3ff7ac9a08
commit
acec282709
16 changed files with 128 additions and 69 deletions
26
file.go
26
file.go
|
@ -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 ""
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue