Extracted golang comment format function
This commit is contained in:
parent
30e02dc9c0
commit
64884e4969
7 changed files with 50 additions and 44 deletions
13
generator/template/format.go
Normal file
13
generator/template/format.go
Normal 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, "")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue