func (g *stubGenerator) getNormalizedResults(context *resolution.LocatorContext, funcType *ast.FuncType) ([]*ast.Field, error) { normalizedResults := []*ast.Field{} resultIndex := 1 for result := range util.EachFieldInFieldList(funcType.Results) { count := util.FieldTypeReuseCount(result) for i := 0; i < count; i++ { fieldName := fmt.Sprintf("result%d", resultIndex) fieldType, err := g.resolver.ResolveType(context, result.Type) if err != nil { return nil, err } normalizedResult := util.CreateField(fieldName, fieldType) normalizedResults = append(normalizedResults, normalizedResult) resultIndex++ } } return normalizedResults, nil }
func (g *stubGenerator) getNormalizedParams(context *resolution.LocatorContext, funcType *ast.FuncType) ([]*ast.Field, error) { normalizedParams := []*ast.Field{} paramIndex := 1 for param := range util.EachFieldInFieldList(funcType.Params) { count := util.FieldTypeReuseCount(param) for i := 0; i < count; i++ { fieldName := fmt.Sprintf("arg%d", paramIndex) fieldType, err := g.resolver.ResolveType(context, param.Type) if err != nil { return nil, err } normalizedParam := util.CreateField(fieldName, fieldType) normalizedParams = append(normalizedParams, normalizedParam) paramIndex++ } } return normalizedParams, nil }