(scanner *bufio.Scanner, line string, pkg string, path string)
| 63 | } |
| 64 | |
| 65 | func parseStruct(scanner *bufio.Scanner, line string, pkg string, path string) { |
| 66 | name := getName(line) |
| 67 | s := Struct{ |
| 68 | Name: name, |
| 69 | Package: pkg, |
| 70 | FilePath: path, |
| 71 | Embeds: make(map[string]bool), |
| 72 | } |
| 73 | // Read the fields of this struct |
| 74 | for scanner.Scan() { |
| 75 | structLine := removeComments(scanner, scanner.Text()) |
| 76 | log(structLine) |
| 77 | if structLine == "}" { |
| 78 | break |
| 79 | } |
| 80 | if structLine == "" { |
| 81 | continue |
| 82 | } |
| 83 | if strings.HasSuffix(structLine, " struct {") { |
| 84 | for scanner.Scan() { |
| 85 | if strings.TrimSpace(scanner.Text()) == "}," { |
| 86 | break |
| 87 | } |
| 88 | } |
| 89 | continue |
| 90 | } |
| 91 | fields, hasStructs := getStructs(structLine) |
| 92 | if hasStructs { |
| 93 | for _, f := range fields { |
| 94 | s.Embeds[f] = true |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // Add to the list |
| 100 | log(fmt.Sprintf("%+v\n", s)) |
| 101 | structsList = append(structsList, s) |
| 102 | } |
| 103 | |
| 104 | func getStructs(s string) ([]string, bool) { |
| 105 | tokens := strings.Fields(cleanTags(s)) |
no test coverage detected