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

@ -1,20 +1,8 @@
package metadata
import "regexp"
// Enum metadata struct
type Enum struct {
Name string `sql:"primary_key"`
Comment string
Values []string
}
// GoLangComment returns enum comment without ascii control characters
func (e Enum) GoLangComment() string {
if e.Comment == "" {
return ""
}
// remove ascii control characters from string
return regexp.MustCompile(`[[:cntrl:]]+`).ReplaceAllString(e.Comment, "")
}