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

proposal: x/tools/cmd/guru: Add option -allowerrors to perform analysis ignoring errors in packages in scope #16533

Closed
keymon opened this issue Jul 29, 2016 · 5 comments

Comments

@keymon
Copy link

keymon commented Jul 29, 2016

Context and problem to solve

Currently guru will abort if any package in the scope has some I/O, parser or type error. There is no way to disable this behaviour.

guru is used for multiple plugins in different editors and IDEs (e.g. vim-go, vscode-go, go-plus for atom). In development environments it is common to be used in code trees where there might be files which some errors, missing dependencies, etc.

It is quite inconvenient not be able to use guru for code analysis simply because some .go fails. It would be desirable if guru had some option to ignore such error, ignoring the package during analysis.

Proposal

I propose add an option -allowerrors which would enable the flag loader.Config.AllowErrors:

If AllowErrors is true, Load will return a Program even
if some of the its packages contained I/O, parser or type
errors; such errors are accessible via PackageInfo.Errors. If
false, Load will fail if any package had an error.

With this option guru will still print the errors in stderr, but ignore the packages with errors and perform the analysis.

@keymon
Copy link
Author

keymon commented Jul 29, 2016

Got a functional fork in https://github.com/keymon/tools/tree/guru_allowerrors

@keymon
Copy link
Author

keymon commented Jul 29, 2016

@quentinmit quentinmit added this to the Unreleased milestone Jul 29, 2016
@quentinmit
Copy link
Contributor

This seems dangerous to me; if the packages fail to parse, the output of guru will be incomplete. This might cause more problems than it solves if e.g. someone is using guru to help with a refactoring.

@keymon
Copy link
Author

keymon commented Jul 29, 2016

That is why it must be optional and disabled by default.

@alandonovan
Copy link
Contributor

I'm not sure what you mean by "Currently guru will abort if any package ... has some I/O, parser or type error." Guru has always set the AllowErrors flag for type-based queries such as describe, definition, and implements. For queries that need pointer analysis (callers, callees, pointsto, and others), there is no point setting this flag since SSA construction and pointer analysis require a well-formed program.

@golang golang locked and limited conversation to collaborators Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants