Skip to content

Commit

Permalink
fix:set package name
Browse files Browse the repository at this point in the history
  • Loading branch information
idersec committed Aug 17, 2021
1 parent 95c3e48 commit ec87a8b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions internal/check/checkinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (f *InterfaceMethod) checkResult(result []parser.Param) (err error) {
if !f.ResultData.IsNull() {
return fmt.Errorf("query method cannot return more than 1 data value in [%s.%s]", f.InterfaceName, f.MethodName)
}
if param.Package == "" && !(param.AllowType() || param.IsMap() || param.IsTime()) {
param.Package = f.Package
}

param.SetName("result")
f.ResultData = param
//return fmt.Errorf("illegal parameter:%s.%s on struct %s.%s generated method %s", param.Package, param.Type, f.OriginStruct.Package, f.OriginStruct.Type, f.MethodName)
Expand Down
2 changes: 0 additions & 2 deletions internal/parser/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ func GetInterfacePath(v interface{}) (paths []*InterfacePath, err error) {
arg := value.Type().In(i)
path.FullName = arg.String()

path.Package = arg.String()

// keep the last model
for _, n := range strings.Split(arg.String(), ".") {
path.Name = n
Expand Down
2 changes: 1 addition & 1 deletion internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (i *InterfaceSet) ParseFile(paths []*InterfacePath) error {
return fmt.Errorf("file not found:%s", file)
}

err = i.getInterfaceFromFile(absFilePath, path.Name, path.Package)
err = i.getInterfaceFromFile(absFilePath, path.Name, path.FullName)
if err != nil {
return fmt.Errorf("can't get interface from %s:%s", path.FullName, err)
}
Expand Down

0 comments on commit ec87a8b

Please sign in to comment.