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

39
errors.go Normal file
View file

@ -0,0 +1,39 @@
package assert
import (
"runtime/debug"
"strings"
)
const oneParameter = `
%s
󰅙 assert.%s
󰯬 %v`
const twoParameters = `
%s
󰅙 assert.%s
󰯬 %v
󰯯 %v`
// file returns the first line containing "_test.go" in the debug stack.
func file() string {
stack := string(debug.Stack())
lines := strings.Split(stack, "\n")
name := ""
for _, line := range lines {
if strings.Contains(line, "_test.go") {
space := strings.LastIndex(line, " ")
if space != -1 {
line = line[:space]
}
name = strings.TrimSpace(line)
break
}
}
return name
}