File tree 2 files changed +17
-2
lines changed 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -845,8 +845,7 @@ func (p *Processor) findRHS(node ast.Node) []string {
845
845
case * ast.BasicLit , * ast.SelectStmt , * ast.ChanType ,
846
846
* ast.LabeledStmt , * ast.DeclStmt , * ast.BranchStmt ,
847
847
* ast.TypeSpec , * ast.ArrayType , * ast.CaseClause ,
848
- * ast.CommClause , * ast.KeyValueExpr , * ast.MapType ,
849
- * ast.FuncLit :
848
+ * ast.CommClause , * ast.MapType , * ast.FuncLit :
850
849
// Nothing to add to RHS
851
850
case * ast.Ident :
852
851
return []string {t .Name }
@@ -905,6 +904,9 @@ func (p *Processor) findRHS(node ast.Node) []string {
905
904
rhs = append (rhs , p .findRHS (t .X )... )
906
905
rhs = append (rhs , p .findRHS (t .Low )... )
907
906
rhs = append (rhs , p .findRHS (t .High )... )
907
+ case * ast.KeyValueExpr :
908
+ rhs = p .findRHS (t .Key )
909
+ rhs = append (rhs , p .findRHS (t .Value )... )
908
910
default :
909
911
if x , ok := maybeX (t ); ok {
910
912
return p .findRHS (x )
Original file line number Diff line number Diff line change @@ -1921,6 +1921,19 @@ func TestWithConfig(t *testing.T) {
1921
1921
reasonShortDeclNotExclusive ,
1922
1922
},
1923
1923
},
1924
+ {
1925
+ description : "key value pairs can use variables" ,
1926
+ code : []byte (`package main
1927
+
1928
+ func main() {
1929
+ someData := GetSomeData()
1930
+ log.WithFields(log.Fields{
1931
+ "data1": someData.One,
1932
+ "data2": someData.Two,
1933
+ "data3": someData.Three,
1934
+ }).Debug("Got some data")
1935
+ }` ),
1936
+ },
1924
1937
}
1925
1938
1926
1939
for _ , tc := range cases {
You can’t perform that action at this time.
0 commit comments