Replace gorm.io/gen header with gormcol

This commit is contained in:
2026-03-29 18:51:45 +02:00
parent 987e55de10
commit 894cd458f5
4 changed files with 11 additions and 62 deletions

11
gen.go
View File

@@ -336,6 +336,11 @@ func (m *GormGen) cleanModelContent(content []byte) []byte {
for _, line := range lines {
trimmed := strings.TrimSpace(line)
// Skip gorm.io/gen header comments.
if strings.Contains(trimmed, "Code generated by gorm.io/gen") {
continue
}
if trimmed == "import (" {
importStarted = true
newLines = append(newLines, line)
@@ -368,5 +373,11 @@ func (m *GormGen) cleanModelContent(content []byte) []byte {
result = strings.Join(newLines, "\n")
result = strings.ReplaceAll(result, "psCategoryDo", "")
// Remove leading empty lines.
result = strings.TrimLeft(result, "\n")
// Add gormcol header comment at the top.
result = "// Code generated by gormcol. DO NOT EDIT.\n\n" + result
return []byte(result)
}