Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix conflict with the import package name #2610

Merged
merged 2 commits into from Nov 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions tools/goctl/api/parser/parser.go
Expand Up @@ -18,19 +18,19 @@ type parser struct {
// Parse parses the api file
func Parse(filename string) (*spec.ApiSpec, error) {
astParser := ast.NewParser(ast.WithParserPrefix(filepath.Base(filename)), ast.WithParserDebug())
ast, err := astParser.Parse(filename)
parsedApi, err := astParser.Parse(filename)
if err != nil {
return nil, err
}

spec := new(spec.ApiSpec)
p := parser{ast: ast, spec: spec}
apiSpec := new(spec.ApiSpec)
p := parser{ast: parsedApi, spec: apiSpec}
err = p.convert2Spec()
if err != nil {
return nil, err
}

return spec, nil
return apiSpec, nil
}

func parseContent(content string, skipCheckTypeDeclaration bool, filename ...string) (*spec.ApiSpec, error) {
Expand All @@ -40,19 +40,19 @@ func parseContent(content string, skipCheckTypeDeclaration bool, filename ...str
} else {
astParser = ast.NewParser()
}
ast, err := astParser.ParseContent(content, filename...)
parsedApi, err := astParser.ParseContent(content, filename...)
if err != nil {
return nil, err
}

spec := new(spec.ApiSpec)
p := parser{ast: ast, spec: spec}
apiSpec := new(spec.ApiSpec)
p := parser{ast: parsedApi, spec: apiSpec}
err = p.convert2Spec()
if err != nil {
return nil, err
}

return spec, nil
return apiSpec, nil
}

// ParseContent parses the api content
Expand Down