refactor(i18n): shorten handler names in state snapshots
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
4608de8def
commit
0e01e9f894
1 changed files with 11 additions and 1 deletions
12
state.go
12
state.go
|
|
@ -1,6 +1,8 @@
|
|||
package i18n
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"dappco.re/go/core"
|
||||
)
|
||||
|
||||
|
|
@ -82,7 +84,7 @@ func (s ServiceState) String() string {
|
|||
names = append(names, "<nil>")
|
||||
continue
|
||||
}
|
||||
names = append(names, core.Sprintf("%T", handler))
|
||||
names = append(names, shortHandlerTypeName(handler))
|
||||
}
|
||||
handlers = "[" + core.Join(", ", names...) + "]"
|
||||
}
|
||||
|
|
@ -104,6 +106,14 @@ func (s ServiceState) String() string {
|
|||
)
|
||||
}
|
||||
|
||||
func shortHandlerTypeName(handler KeyHandler) string {
|
||||
name := core.Sprintf("%T", handler)
|
||||
if idx := strings.LastIndex(name, "."); idx >= 0 {
|
||||
name = name[idx+1:]
|
||||
}
|
||||
return strings.TrimPrefix(name, "*")
|
||||
}
|
||||
|
||||
func (s *Service) State() ServiceState {
|
||||
if s == nil {
|
||||
return defaultServiceStateSnapshot()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue