(file *ast.File, baseDir string)
| 47 | } |
| 48 | |
| 49 | func GetEmbedDetailsForFile(file *ast.File, baseDir string) []*EmbedDetails { |
| 50 | var result []*EmbedDetails |
| 51 | for _, comment := range file.Comments { |
| 52 | for _, c := range comment.List { |
| 53 | if strings.HasPrefix(c.Text, "//go:embed") { |
| 54 | sl := strings.Split(c.Text, " ") |
| 55 | if len(sl) == 1 { |
| 56 | continue |
| 57 | } |
| 58 | // support for multiple paths in one comment |
| 59 | for _, arg := range sl[1:] { |
| 60 | embedPath := strings.TrimSpace(arg) |
| 61 | // ignores all pattern matching characters except escape sequence |
| 62 | if strings.Contains(embedPath, "*") || strings.Contains(embedPath, "?") || strings.Contains(embedPath, "[") { |
| 63 | continue |
| 64 | } |
| 65 | if strings.HasPrefix(embedPath, "all:") { |
| 66 | result = append(result, &EmbedDetails{ |
| 67 | EmbedPath: strings.TrimPrefix(embedPath, "all:"), |
| 68 | All: true, |
| 69 | BaseDir: baseDir, |
| 70 | }) |
| 71 | } else { |
| 72 | result = append(result, &EmbedDetails{ |
| 73 | EmbedPath: embedPath, |
| 74 | All: false, |
| 75 | BaseDir: baseDir, |
| 76 | }) |
| 77 | } |
| 78 | |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | return result |
| 84 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…