package prepare import ( "log" "strings" "git.ymnuktech.ru/ymnuk/yt-gen-app/lib/templ" "git.ymnuktech.ru/ymnuk/yt-gen-app/structs" uuid "github.com/satori/go.uuid" ) func prepareInterfaces(project *structs.Project) *structs.Project { if len(project.Interfaces) == 0 { return project } for i := range project.Interfaces { project.Interfaces[i].Name = strings.Trim(project.Interfaces[i].Name, " ") if project.Interfaces[i].Name == "" { log.Fatal("Name interface is empty") } project.Interfaces[i].Name = templ.FieldNamePrepare(project.Interfaces[i].Name) if project.Interfaces[i].ID == uuid.Nil { project.Interfaces[i].ID = uuid.NewV4() } if len(project.Interfaces[i].Fields) == 0 { continue } for j := range project.Interfaces[i].Fields { if project.Interfaces[i].Fields[j].ID == uuid.Nil { project.Interfaces[i].Fields[j].ID = uuid.NewV4() } project.Interfaces[i].Fields[j].Name = strings.Trim(project.Interfaces[i].Fields[j].Name, " ") if project.Interfaces[i].Fields[j].Name == "" { log.Fatalf("Field in interface %s should be set", project.Interfaces[i].Name) } project.Interfaces[i].Fields[j].Name = templ.FieldNamePrepare(project.Interfaces[i].Fields[j].Name) } } return project }