Skip to content

Commit

Permalink
fix reflection in component name getter
Browse files Browse the repository at this point in the history
  • Loading branch information
yznts committed Jan 29, 2024
1 parent 035f558 commit 1dd6b56
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Component func(ctx *Context) State
func (c Component) GetName() string {
functionPath := runtime.FuncForPC(reflect.ValueOf(c).Pointer()).Name()
tokens := strings.Split(functionPath, ".")
if tokens[len(tokens)-1] == "func1" || tokens[len(tokens)-1] == "func2" {
if strings.HasPrefix(tokens[len(tokens)-1], "func") {
return tokens[len(tokens)-2]
} else {
return tokens[len(tokens)-1]
Expand Down

0 comments on commit 1dd6b56

Please sign in to comment.