no trailing comma on label list

This commit is contained in:
William Banfield
2022-05-12 13:54:34 -04:00
parent 1fb1b2f1d1
commit cb6bddab70
2 changed files with 4 additions and 4 deletions

View File

@@ -272,11 +272,11 @@ func extractHelpMessage(cg *ast.CommentGroup) string {
}
var help []string
for _, c := range cg.List {
mt := strings.TrimPrefix(str, "//metrics:")
if mt != c {
mt := strings.TrimPrefix(c.Text, "//metrics:")
if mt != c.Text {
return strings.TrimSpace(mt)
}
help = append(help, strings.TrimSpace(strings.TrimPrefix(c, "//")))
help = append(help, strings.TrimSpace(strings.TrimPrefix(c.Text, "//")))
}
return strings.Join(help, " ")
}

View File

@@ -158,7 +158,7 @@ func TestParseMetricsStruct(t *testing.T) {
TypeName: "Counter",
FieldName: "myCounter",
MetricName: "my_counter",
Labels: "\"label1\",\"label2\",",
Labels: "\"label1\",\"label2\"",
},
},
},