Description
This issue proposes the following additions to x/tools/go/analysis
type Analyzer struct {
// URL holds an optional link to a web page with additional documentation for this analyzer.
// This value will be used as the default value of Diagnostic.URL for diagnostics produced via
// the Pass.Reportf API.
URL string
//...
}
type Diagnostic struct {
// URL holds an optional link to a web page with additional documentation for this diagnostic.
URL string
//...
}
Background: #57903 reverted an ad-hoc URL formatted in the printf analyzer diagnostic message, as it adds unnecessary verbosity and is inconsistent with other vet errors. However, this URL was added based on evidence that some users are confused about how to fix printf formatting verb mismatches.
There is inherent tension in error messages because while we want vet errors to be as concise as possible, some users need more information to understand the error, particularly the first time they see it.
Adding a URL field to analyzers and diagnostics would allow tools to serve the user additional documentation in whatever form is most appropriate. For example, cmd/vet
could have a flag that controls this information (-url
?), and gopls could set the LSP codeDescription.