Replace gorm.io/gen header with gormcol
This commit is contained in:
11
gen.go
11
gen.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user