Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(plugin): Exception when registering a plugin and finding that the slug_name is not unique.

LinkinStarsd5b5d9a51cec
diff --git a/plugin/plugin.go b/plugin/plugin.go
index 43fef87f..6e640619 100644
--- a/plugin/plugin.go
+++ b/plugin/plugin.go
@@ -73,6 +73,11 @@ func MakePlugin[T Base](super bool) (CallFn[T], RegisterFn[T]) {
}
register := func(p T) {
+ for _, plugin := range stack.plugins {
+ if plugin.Info().SlugName == p.Info().SlugName {
+ panic("plugin " + p.Info().SlugName + " is already registered")
+ }
+ }
stack.plugins = append(stack.plugins, p)
}