INNER CODE UNIT · Go

dedupeJSONBlock

stacklok/toolhive · cmd/help/dedupe-enums/main.go:56

func dedupeJSONBlock(match string) string {
	g := jsonArray.FindStringSubmatch(match)
	header, body, footer := g[1], g[2], g[3]

	lines := strings.Split(strings.TrimRight(body, "\n"), "\n")
	trimmed := make([]string, len(lines))
	for i, l := range lines {
		trimmed[i] = strings.TrimSuffix(l, ",")
	}

	period, ok := firstPeriodIfRepeated(trimmed)
	if !ok {
		return match
	}
	return header + strings.Join(period, ",\n") + "\n" + footer
}

func dedupeYAMLBlock(match string) string {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…