45 lines
641 B
Go
45 lines
641 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestStack(t *testing.T) {
|
|
fmt.Println(Stack())
|
|
}
|
|
|
|
func TestCallerFull(t *testing.T) {
|
|
fmt.Println(CallerFull(1))
|
|
}
|
|
|
|
func TestCallerMod(t *testing.T) {
|
|
fmt.Println(CallerMod(1))
|
|
}
|
|
|
|
func TestCaller(t *testing.T) {
|
|
fmt.Println(Caller(1))
|
|
}
|
|
|
|
func TestStringer(t *testing.T) {
|
|
f := "test/cbox@v0.0.0-20211216161916-9173e9f37ab9/service.go"
|
|
ptr := 0
|
|
file := ""
|
|
mod := ""
|
|
for i := len(f) - 1; i > 0; i-- {
|
|
if f[i] == '/' {
|
|
if ptr == 0 {
|
|
file = f[i+1:]
|
|
ptr = i
|
|
} else {
|
|
mod = f[i+1 : ptr]
|
|
break
|
|
}
|
|
}
|
|
if f[i] == '@' {
|
|
ptr = i
|
|
}
|
|
}
|
|
fmt.Println(mod, file)
|
|
}
|