Extracted golang comment format function

This commit is contained in:
Volker Lieber 2024-09-26 14:17:21 +02:00
parent 30e02dc9c0
commit 64884e4969
7 changed files with 50 additions and 44 deletions

View file

@ -0,0 +1,13 @@
package template
import "regexp"
// Returns the provided string as golang comment without ascii control characters
func formatGolangComment(comment string) string {
if len(comment) == 0 {
return ""
}
// Format as colang comment and remove ascii control characters from string
return "// " + regexp.MustCompile(`[[:cntrl:]]+`).ReplaceAllString(comment, "")
}