extractStringSlice extracts a []string from a composite literal. Example: - []string{"a", "b", myConst}: ["a", "b", ]
(lit *ast.CompositeLit, decls declarations)
| 310 | // Example: |
| 311 | // - []string{"a", "b", myConst}: ["a", "b", <resolved value of myConst>] |
| 312 | func extractStringSlice(lit *ast.CompositeLit, decls declarations) []string { |
| 313 | var labels []string |
| 314 | for _, elt := range lit.Elts { |
| 315 | if label := resolveStringExpr(elt, decls); label != "" { |
| 316 | labels = append(labels, label) |
| 317 | } |
| 318 | } |
| 319 | return labels |
| 320 | } |
| 321 | |
| 322 | // collectDecls collects const and var declarations from a file. |
| 323 | // This is used to resolve constant and variable references in metric definitions. |
no test coverage detected