UserTypeLocation returns the location of the user type if set via the struct:pkg:path metadata, nil otherwise..
(dt expr.DataType)
| 77 | // UserTypeLocation returns the location of the user type if set via the |
| 78 | // struct:pkg:path metadata, nil otherwise.. |
| 79 | func UserTypeLocation(dt expr.DataType) *Location { |
| 80 | ut, ok := dt.(expr.UserType) |
| 81 | if !ok { |
| 82 | return nil |
| 83 | } |
| 84 | p, ok := ut.Attribute().Meta.Last("struct:pkg:path") |
| 85 | if !ok || p == "" { |
| 86 | return nil |
| 87 | } |
| 88 | return &Location{ |
| 89 | FilePath: filepath.Join(filepath.FromSlash(p), SnakeCase(ut.Name())+".go"), |
| 90 | RelImportPath: p, |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // PackageName returns the package name of the given location. |
| 95 | func (loc *Location) PackageName() string { |
no test coverage detected