Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Commit 675556c

Browse files
committed
Accept struct initialization without field names
Signed-off-by: Ji-Ping Shen [email protected]
1 parent b985ac7 commit 675556c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/analyzer/analyzer.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,19 @@ func run(pass *analysis.Pass) (interface{}, error) {
153153
continue
154154
}
155155

156-
for _, e := range compositeLit.Elts {
156+
for eIndex, e := range compositeLit.Elts {
157157
if k, ok := e.(*ast.KeyValueExpr); ok {
158158
if i, ok := k.Key.(*ast.Ident); ok {
159159
if i.Name == fieldName {
160160
exists = true
161161
break
162162
}
163163
}
164+
} else {
165+
if eIndex == i {
166+
exists = true
167+
break
168+
}
164169
}
165170
}
166171

0 commit comments

Comments
 (0)