()
| 57 | ) |
| 58 | |
| 59 | func init() { |
| 60 | highprios := make([]string, 0, 64) |
| 61 | midprios := make([]string, 0, 64) |
| 62 | lowprios := make([]string, 0, 64) |
| 63 | |
| 64 | status := statusnone |
| 65 | scanner := bufio.NewScanner(strings.NewReader(maincode)) |
| 66 | for scanner.Scan() { |
| 67 | line := scanner.Text() |
| 68 | |
| 69 | prioword := "" |
| 70 | match := priore.FindStringSubmatch(line) |
| 71 | if len(match) > 1 { |
| 72 | prioword = match[1] |
| 73 | } |
| 74 | switch prioword { |
| 75 | case "高": |
| 76 | switch status { |
| 77 | case statusnone: |
| 78 | status = statushigh |
| 79 | case statushigh: |
| 80 | status = statushighend |
| 81 | default: |
| 82 | panic("unexpected") |
| 83 | } |
| 84 | case "中": |
| 85 | switch status { |
| 86 | case statushighend: |
| 87 | status = statusmid |
| 88 | case statusmid: |
| 89 | status = statusmidend |
| 90 | default: |
| 91 | panic("unexpected") |
| 92 | } |
| 93 | case "低": |
| 94 | switch status { |
| 95 | case statusmidend: |
| 96 | status = statuslow |
| 97 | case statuslow: |
| 98 | status = statuslowend |
| 99 | default: |
| 100 | panic("unexpected") |
| 101 | } |
| 102 | default: |
| 103 | switch status { |
| 104 | case statusnone: // 还未开始匹配 |
| 105 | continue |
| 106 | case statuslowend: // 匹配已结束 |
| 107 | break |
| 108 | default: // 继续匹配插件 |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | // 在对应优先级区域内匹配插件 |
| 113 | if matches := mainpluginre.FindStringSubmatch(line); len(matches) > 1 { |
| 114 | name := matches[1] |
| 115 | switch status { |
| 116 | case statushigh: |
nothing calls this directly
no outgoing calls
no test coverage detected