github.com/wawandco/oxplugins@v0.7.11/tools/buffalo/model/imports.go (about) 1 package model 2 3 import ( 4 "sort" 5 "strings" 6 ) 7 8 func buildImports(attrs []attr) []string { 9 imps := map[string]bool{"fmt": true} 10 11 ats := attrs 12 for _, a := range ats { 13 switch a.GoType() { 14 case "uuid", "uuid.UUID": 15 imps["github.com/gofrs/uuid"] = true 16 case "time.Time": 17 imps["time"] = true 18 default: 19 if strings.HasPrefix(a.GoType(), "nulls") { 20 imps["github.com/gobuffalo/nulls"] = true 21 } 22 if strings.HasPrefix(a.GoType(), "slices") { 23 imps["github.com/gobuffalo/pop/v5/slices"] = true 24 } 25 } 26 } 27 28 i := make([]string, 0, len(imps)) 29 for k := range imps { 30 i = append(i, k) 31 } 32 33 sort.Strings(i) 34 35 return i 36 }