go/analysis/passes/composite: add an example to the doc
Change-Id: I929a5390aa5f4a4484e57ffa1eaa66f3238da1c1 Reviewed-on: https://go-review.googlesource.com/c/159338 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
78ee07aa94
commit
a78a3054ec
|
@ -21,7 +21,16 @@ const Doc = `check for unkeyed composite literals
|
|||
This analyzer reports a diagnostic for composite literals of struct
|
||||
types imported from another package that do not use the field-keyed
|
||||
syntax. Such literals are fragile because the addition of a new field
|
||||
(even if unexported) to the struct will cause compilation to fail.`
|
||||
(even if unexported) to the struct will cause compilation to fail.
|
||||
|
||||
As an example,
|
||||
|
||||
err = &net.DNSConfigError{err}
|
||||
|
||||
should be replaced by:
|
||||
|
||||
err = &net.DNSConfigError{Err: err}
|
||||
`
|
||||
|
||||
var Analyzer = &analysis.Analyzer{
|
||||
Name: "composites",
|
||||
|
|
Loading…
Reference in New Issue