mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
//go:build tools
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
sqlDir := "internal/data/sql"
|
|
|
|
files, err := ioutil.ReadDir(sqlDir)
|
|
if err != nil {
|
|
fmt.Println("Error reading sql directory:", err)
|
|
return
|
|
}
|
|
|
|
for _, file := range files {
|
|
if strings.HasSuffix(file.Name(), "_repository.go") {
|
|
repoName := strings.TrimSuffix(file.Name(), "_repository.go")
|
|
filePath := filepath.Join(sqlDir, file.Name())
|
|
|
|
content, err := ioutil.ReadFile(filePath)
|
|
if err != nil {
|
|
fmt.Printf("Error reading file %s: %v\n", filePath, err)
|
|
continue
|
|
}
|
|
|
|
newContent := strings.Replace(string(content), `"tercul/internal/domain"`, fmt.Sprintf(`"%s"`, filepath.Join("tercul/internal/domain", repoName)), 1)
|
|
newContent = strings.Replace(newContent, "domain."+strings.Title(repoName)+"Repository", repoName+"."+strings.Title(repoName)+"Repository", 1)
|
|
|
|
if err := ioutil.WriteFile(filePath, []byte(newContent), 0644); err != nil {
|
|
fmt.Printf("Error writing file %s: %v\n", filePath, err)
|
|
} else {
|
|
fmt.Printf("Fixed imports in %s\n", filePath)
|
|
}
|
|
}
|
|
}
|
|
}
|