wu-sheng commented on a change in pull request #12:
URL: 
https://github.com/apache/skywalking-satellite/pull/12#discussion_r551304483



##########
File path: internal/pkg/plugin/definition.go
##########
@@ -53,14 +55,16 @@ type Config map[string]interface{}
 // GetPluginName returns a plugin name generated by the packages.
 // Recommended plugin directory structure: 
plugins/{plugin-category}/{plugin-name}, so the generated names is 
{plugin-name}-{plugin-category}.
 func GetPluginName(p Plugin) string {
-       nameParts := 2
        t := reflect.TypeOf(p)
        if t.Kind() == reflect.Ptr {
                t = t.Elem()
        }
-       arr := strings.Split(t.PkgPath(), "/")
-       if len(arr) < nameParts {
-               return ""
+       path := t.PkgPath()
+       path = path[strings.LastIndex(path, PluginDir)+len(PluginDir)+1:]
+       arr := strings.Split(path, "/")
+       if len(arr) > 1 {
+               category := arr[0]
+               return strings.Join(arr[1:], "-") + "-" + category

Review comment:
       As you asked, personally, prefer to use `plugin.Name()` to simplify.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to