From a78a3054ec8e347bbf61862726567d29bfbcc101 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Thu, 24 Jan 2019 12:48:11 -0500 Subject: [PATCH] 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 --- go/analysis/passes/composite/composite.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/go/analysis/passes/composite/composite.go b/go/analysis/passes/composite/composite.go index 9cca7781..2abe7c6d 100644 --- a/go/analysis/passes/composite/composite.go +++ b/go/analysis/passes/composite/composite.go @@ -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",