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

x/tools/go/analysis/passes/tests: should it re-use go/doc's example classification logic, or continue to implement its own? #36184

Closed
dmitshur opened this issue Dec 17, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Dec 17, 2019

A part of the functionality in the function checkExample parses the name of the example and reports if it refers to an unknown identifier, field, or method.

Before #23864 was resolved, there was no choice but for tests to implement this logic itself. Now that #23864 is resolved, it may be possible for tests to reuse some of the logic from go/doc in Go 1.14 and newer.

This issue is to investigate and answer the question of: should it? Would it be better to reuse that logic, or is it better to continue to implement the example naming classification a second time for the needs of tests?

Note that the text of diagnostics that the tests pass emits should not be made worse if this implementation change were to happen.

/cc @jayconrod @matloob @bcmills

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 17, 2019
@dmitshur dmitshur added this to the Backlog milestone Dec 17, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Dec 17, 2019
@matloob
Copy link
Contributor

matloob commented Dec 17, 2019

This change might be cumbersome because we'd still have to match up the examples returned from go/doc.Examples with the one that's being checked in checkExample, and some of the logic in checkExample will need to stay (checking arguments, return types) because go/doc.Examples throws the function signature.

@jayconrod
Copy link
Contributor

I don't know much about the tests pass, but doesn't it need to identify functions that are intended by the user to be examples but aren't returned by go/doc.Examples? If that's the case, then it has to have its own implementation.

@dmitshur
Copy link
Contributor Author

It sounds like there isn't a way to use the new example classification functionality in go/doc in a beneficial way for the needs of tests. I'll close this for now, but if we later find some opportunity to benefit from go/doc after all, we can reopen this.

@golang golang locked and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants