master
Evan Chen 2021-12-17 00:25:29 +08:00
parent ebf2951ea3
commit 0a47f12905
4 changed files with 30 additions and 2 deletions

View File

@ -29,6 +29,7 @@ func New(s *server.Service) *Service {
func (srv Service) GetName() string { return "auth.Service" } func (srv Service) GetName() string { return "auth.Service" }
func (srv Service) GetDependencies() []string { return []string{"server.Service", "auth.Auth"} } func (srv Service) GetDependencies() []string { return []string{"server.Service", "auth.Auth"} }
func (srv Service) IsService() bool { return true }
func (srv Service) Init() error { func (srv Service) Init() error {
srv.Logger = log.With().Str("mod", "auth").Str("service", "auth.Service").Logger() srv.Logger = log.With().Str("mod", "auth").Str("service", "auth.Service").Logger()

View File

@ -13,6 +13,8 @@ type Service struct {
func (srv Service) GetName() string { return "history.Service" } func (srv Service) GetName() string { return "history.Service" }
func (srv Service) IsService() bool { return true } func (srv Service) IsService() bool { return true }
func (srv Service) GetDependencies() []string { return []string{"server.Service"} }
func (srv Service) Init() error { func (srv Service) Init() error {
PROD = viper.GetBool("prod") PROD = viper.GetBool("prod")
l := log.With().Str("mod", "history"). l := log.With().Str("mod", "history").

View File

@ -36,6 +36,9 @@ func CallerMod(depth int) (mod, file string) {
break break
} }
} }
if f[i] == '@' {
ptr = i
}
} }
return return
} }

View File

@ -20,3 +20,25 @@ func TestCallerMod(t *testing.T) {
func TestCaller(t *testing.T) { func TestCaller(t *testing.T) {
fmt.Println(Caller(1)) 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)
}