Browse Source

fix type convert error (#395)

kingxt 3 years ago
parent
commit
43e712d86a
1 changed files with 17 additions and 1 deletions
  1. 17 1
      tools/goctl/plugin/plugin.go

+ 17 - 1
tools/goctl/plugin/plugin.go

@@ -161,10 +161,26 @@ func NewPlugin() (*Plugin, error) {
 	if err != nil {
 		return nil, err
 	}
-	err = json.Unmarshal(content, &plugin)
+
+	var info struct {
+		ApiFilePath string
+		Style       string
+		Dir         string
+	}
+	err = json.Unmarshal(content, &info)
 	if err != nil {
 		return nil, err
 	}
+
+	plugin.ApiFilePath = info.ApiFilePath
+	plugin.Style = info.Style
+	plugin.Dir = info.Dir
+	api, err := parser.Parse(info.ApiFilePath)
+	if err != nil {
+		return nil, err
+	}
+
+	plugin.Api = api
 	return &plugin, nil
 }