syncable_cli/analyzer/frameworks/
go.rs

1use super::{LanguageFrameworkDetector, TechnologyRule, FrameworkDetectionUtils};
2use crate::analyzer::{DetectedTechnology, DetectedLanguage, TechnologyCategory, LibraryType};
3use crate::error::Result;
4
5pub struct GoFrameworkDetector;
6
7impl LanguageFrameworkDetector for GoFrameworkDetector {
8    fn detect_frameworks(&self, language: &DetectedLanguage) -> Result<Vec<DetectedTechnology>> {
9        let rules = get_go_technology_rules();
10        
11        // Combine main and dev dependencies for comprehensive detection
12        let all_deps: Vec<String> = language.main_dependencies.iter()
13            .chain(language.dev_dependencies.iter())
14            .cloned()
15            .collect();
16        
17        let technologies = FrameworkDetectionUtils::detect_technologies_by_dependencies(
18            &rules, &all_deps, language.confidence
19        );
20        
21        Ok(technologies)
22    }
23    
24    fn supported_languages(&self) -> Vec<&'static str> {
25        vec!["Go"]
26    }
27}
28
29/// Go technology detection rules with comprehensive framework coverage
30fn get_go_technology_rules() -> Vec<TechnologyRule> {
31    vec![
32        // WEB FRAMEWORKS
33        TechnologyRule {
34            name: "Gin".to_string(),
35            category: TechnologyCategory::BackendFramework,
36            confidence: 0.95,
37            dependency_patterns: vec!["github.com/gin-gonic/gin".to_string(), "gin-gonic".to_string()],
38            requires: vec![],
39            conflicts_with: vec![],
40            is_primary_indicator: true,
41            alternative_names: vec!["gin-gonic".to_string()],
42            file_indicators: vec![],
43        },
44        TechnologyRule {
45            name: "Echo".to_string(),
46            category: TechnologyCategory::BackendFramework,
47            confidence: 0.95,
48            dependency_patterns: vec!["github.com/labstack/echo".to_string(), "labstack/echo".to_string()],
49            requires: vec![],
50            conflicts_with: vec![],
51            is_primary_indicator: true,
52            alternative_names: vec!["labstack/echo".to_string()],
53            file_indicators: vec![],
54        },
55        TechnologyRule {
56            name: "Fiber".to_string(),
57            category: TechnologyCategory::BackendFramework,
58            confidence: 0.95,
59            dependency_patterns: vec!["github.com/gofiber/fiber".to_string(), "gofiber".to_string()],
60            requires: vec![],
61            conflicts_with: vec![],
62            is_primary_indicator: true,
63            alternative_names: vec!["gofiber".to_string()],
64            file_indicators: vec![],
65        },
66        TechnologyRule {
67            name: "Chi".to_string(),
68            category: TechnologyCategory::BackendFramework,
69            confidence: 0.90,
70            dependency_patterns: vec!["github.com/go-chi/chi".to_string(), "go-chi/chi".to_string()],
71            requires: vec![],
72            conflicts_with: vec![],
73            is_primary_indicator: true,
74            alternative_names: vec!["chi".to_string()],
75            file_indicators: vec![],
76        },
77        TechnologyRule {
78            name: "Gorilla Mux".to_string(),
79            category: TechnologyCategory::BackendFramework,
80            confidence: 0.90,
81            dependency_patterns: vec!["github.com/gorilla/mux".to_string(), "gorilla/mux".to_string()],
82            requires: vec![],
83            conflicts_with: vec![],
84            is_primary_indicator: true,
85            alternative_names: vec!["mux".to_string()],
86            file_indicators: vec![],
87        },
88        TechnologyRule {
89            name: "HttpRouter".to_string(),
90            category: TechnologyCategory::BackendFramework,
91            confidence: 0.90,
92            dependency_patterns: vec!["github.com/julienschmidt/httprouter".to_string(), "julienschmidt/httprouter".to_string()],
93            requires: vec![],
94            conflicts_with: vec![],
95            is_primary_indicator: true,
96            alternative_names: vec!["httprouter".to_string()],
97            file_indicators: vec![],
98        },
99        TechnologyRule {
100            name: "Beego".to_string(),
101            category: TechnologyCategory::BackendFramework,
102            confidence: 0.90,
103            dependency_patterns: vec!["github.com/beego/beego".to_string(), "beego/beego".to_string()],
104            requires: vec![],
105            conflicts_with: vec![],
106            is_primary_indicator: true,
107            alternative_names: vec!["beego".to_string()],
108            file_indicators: vec![],
109        },
110        TechnologyRule {
111            name: "Revel".to_string(),
112            category: TechnologyCategory::BackendFramework,
113            confidence: 0.85,
114            dependency_patterns: vec!["github.com/revel/revel".to_string(), "revel/revel".to_string()],
115            requires: vec![],
116            conflicts_with: vec![],
117            is_primary_indicator: true,
118            alternative_names: vec!["revel".to_string()],
119            file_indicators: vec![],
120        },
121        TechnologyRule {
122            name: "Buffalo".to_string(),
123            category: TechnologyCategory::BackendFramework,
124            confidence: 0.85,
125            dependency_patterns: vec!["github.com/gobuffalo/buffalo".to_string(), "gobuffalo/buffalo".to_string()],
126            requires: vec![],
127            conflicts_with: vec![],
128            is_primary_indicator: true,
129            alternative_names: vec!["buffalo".to_string()],
130            file_indicators: vec![],
131        },
132        TechnologyRule {
133            name: "Gin Web Framework".to_string(),
134            category: TechnologyCategory::BackendFramework,
135            confidence: 0.95,
136            dependency_patterns: vec!["github.com/gin-gonic/gin".to_string(), "gin-gonic".to_string()],
137            requires: vec![],
138            conflicts_with: vec![],
139            is_primary_indicator: true,
140            alternative_names: vec!["gin".to_string()],
141            file_indicators: vec![],
142        },
143        TechnologyRule {
144            name: "Go Kit".to_string(),
145            category: TechnologyCategory::Library(LibraryType::Utility),
146            confidence: 0.90,
147            dependency_patterns: vec!["github.com/go-kit/kit".to_string(), "go-kit".to_string()],
148            requires: vec![],
149            conflicts_with: vec![],
150            is_primary_indicator: false,
151            alternative_names: vec!["kit".to_string()],
152            file_indicators: vec![],
153        },
154        TechnologyRule {
155            name: "Micro".to_string(),
156            category: TechnologyCategory::Library(LibraryType::Utility),
157            confidence: 0.90,
158            dependency_patterns: vec!["github.com/micro/micro".to_string(), "micro/micro".to_string()],
159            requires: vec![],
160            conflicts_with: vec![],
161            is_primary_indicator: false,
162            alternative_names: vec!["micro".to_string()],
163            file_indicators: vec![],
164        },
165        TechnologyRule {
166            name: "Go Micro".to_string(),
167            category: TechnologyCategory::Library(LibraryType::Utility),
168            confidence: 0.90,
169            dependency_patterns: vec!["github.com/micro/go-micro".to_string(), "micro/go-micro".to_string()],
170            requires: vec![],
171            conflicts_with: vec![],
172            is_primary_indicator: false,
173            alternative_names: vec!["go-micro".to_string()],
174            file_indicators: vec![],
175        },
176        TechnologyRule {
177            name: "Go Frame".to_string(),
178            category: TechnologyCategory::BackendFramework,
179            confidence: 0.90,
180            dependency_patterns: vec!["github.com/gogf/gf".to_string(), "gogf/gf".to_string()],
181            requires: vec![],
182            conflicts_with: vec![],
183            is_primary_indicator: true,
184            alternative_names: vec!["gf".to_string()],
185            file_indicators: vec![],
186        },
187        TechnologyRule {
188            name: "Iris".to_string(),
189            category: TechnologyCategory::BackendFramework,
190            confidence: 0.90,
191            dependency_patterns: vec!["github.com/kataras/iris".to_string(), "kataras/iris".to_string()],
192            requires: vec![],
193            conflicts_with: vec![],
194            is_primary_indicator: true,
195            alternative_names: vec!["iris".to_string()],
196            file_indicators: vec![],
197        },
198        TechnologyRule {
199            name: "FastHTTP".to_string(),
200            category: TechnologyCategory::BackendFramework,
201            confidence: 0.95,
202            dependency_patterns: vec!["github.com/valyala/fasthttp".to_string(), "fasthttp".to_string()],
203            requires: vec![],
204            conflicts_with: vec![],
205            is_primary_indicator: true,
206            alternative_names: vec!["valyala/fasthttp".to_string()],
207            file_indicators: vec![],
208        },
209        TechnologyRule {
210            name: "Hertz".to_string(),
211            category: TechnologyCategory::BackendFramework,
212            confidence: 0.95,
213            dependency_patterns: vec!["github.com/cloudwego/hertz".to_string()],
214            requires: vec![],
215            conflicts_with: vec![],
216            is_primary_indicator: true,
217            alternative_names: vec!["cloudwego/hertz".to_string()],
218            file_indicators: vec![],
219        },
220        
221        // Encore (Go) - Cloud development platform
222        TechnologyRule {
223            name: "Encore".to_string(),
224            category: TechnologyCategory::BackendFramework,
225            confidence: 0.95,
226            dependency_patterns: vec!["encore.dev".to_string()],
227            requires: vec![],
228            conflicts_with: vec![],
229            is_primary_indicator: true,
230            alternative_names: vec![],
231            file_indicators: vec!["encore.app".to_string()],
232        },
233        
234        // DATABASE/ORM
235        TechnologyRule {
236            name: "GORM".to_string(),
237            category: TechnologyCategory::Database,
238            confidence: 0.90,
239            // Only match the specific gorm.io path, not just "gorm"
240            dependency_patterns: vec!["gorm.io/gorm".to_string()],
241            requires: vec![],
242            conflicts_with: vec![],
243            is_primary_indicator: false,
244            alternative_names: vec![],
245            file_indicators: vec![],
246        },
247        TechnologyRule {
248            name: "Ent".to_string(),
249            category: TechnologyCategory::Database,
250            confidence: 0.90,
251            dependency_patterns: vec!["entgo.io/ent".to_string(), "facebook/ent".to_string()],
252            requires: vec![],
253            conflicts_with: vec![],
254            is_primary_indicator: false,
255            alternative_names: vec!["entgo".to_string()],
256            file_indicators: vec![],
257        },
258        TechnologyRule {
259            name: "Xorm".to_string(),
260            category: TechnologyCategory::Database,
261            confidence: 0.85,
262            dependency_patterns: vec!["xorm.io/xorm".to_string()],
263            requires: vec![],
264            conflicts_with: vec![],
265            is_primary_indicator: false,
266            alternative_names: vec![],
267            file_indicators: vec![],
268        },
269        TechnologyRule {
270            name: "Bun".to_string(),
271            category: TechnologyCategory::Database,
272            confidence: 0.85,
273            dependency_patterns: vec!["github.com/uptrace/bun".to_string(), "uptrace/bun".to_string()],
274            requires: vec![],
275            conflicts_with: vec![],
276            is_primary_indicator: false,
277            alternative_names: vec![],
278            file_indicators: vec![],
279        },
280        TechnologyRule {
281            name: "SQLBoiler".to_string(),
282            category: TechnologyCategory::Database,
283            confidence: 0.85,
284            dependency_patterns: vec!["github.com/volatiletech/sqlboiler".to_string(), "volatiletech/sqlboiler".to_string()],
285            requires: vec![],
286            conflicts_with: vec![],
287            is_primary_indicator: false,
288            alternative_names: vec![],
289            file_indicators: vec![],
290        },
291        TechnologyRule {
292            name: "Squirrel".to_string(),
293            category: TechnologyCategory::Database,
294            confidence: 0.85,
295            dependency_patterns: vec!["github.com/Masterminds/squirrel".to_string(), "Masterminds/squirrel".to_string()],
296            requires: vec![],
297            conflicts_with: vec![],
298            is_primary_indicator: false,
299            alternative_names: vec![],
300            file_indicators: vec![],
301        },
302        
303        // TESTING
304        TechnologyRule {
305            name: "Testify".to_string(),
306            category: TechnologyCategory::Testing,
307            confidence: 0.85,
308            dependency_patterns: vec!["github.com/stretchr/testify".to_string(), "stretchr/testify".to_string()],
309            requires: vec![],
310            conflicts_with: vec![],
311            is_primary_indicator: false,
312            alternative_names: vec!["stretchr/testify".to_string()],
313            file_indicators: vec![],
314        },
315        TechnologyRule {
316            name: "Ginkgo".to_string(),
317            category: TechnologyCategory::Testing,
318            confidence: 0.85,
319            dependency_patterns: vec!["github.com/onsi/ginkgo".to_string()],
320            requires: vec![],
321            conflicts_with: vec![],
322            is_primary_indicator: false,
323            alternative_names: vec!["onsi/ginkgo".to_string()],
324            file_indicators: vec![],
325        },
326        
327        // CLI FRAMEWORKS
328        TechnologyRule {
329            name: "Cobra".to_string(),
330            category: TechnologyCategory::Library(LibraryType::CLI),
331            confidence: 0.85,
332            dependency_patterns: vec!["github.com/spf13/cobra".to_string()],
333            requires: vec![],
334            conflicts_with: vec![],
335            is_primary_indicator: true,
336            alternative_names: vec!["spf13/cobra".to_string()],
337            file_indicators: vec![],
338        },
339        
340        // CONFIG MANAGEMENT
341        TechnologyRule {
342            name: "Viper".to_string(),
343            category: TechnologyCategory::Library(LibraryType::Utility),
344            confidence: 0.80,
345            dependency_patterns: vec!["github.com/spf13/viper".to_string()],
346            requires: vec![],
347            conflicts_with: vec![],
348            is_primary_indicator: false,
349            alternative_names: vec!["spf13/viper".to_string()],
350            file_indicators: vec![],
351        },
352        
353        // LOGGING
354        TechnologyRule {
355            name: "Logrus".to_string(),
356            category: TechnologyCategory::Library(LibraryType::Utility),
357            confidence: 0.85,
358            dependency_patterns: vec!["github.com/sirupsen/logrus".to_string()],
359            requires: vec![],
360            conflicts_with: vec![],
361            is_primary_indicator: false,
362            alternative_names: vec![],
363            file_indicators: vec![],
364        },
365        TechnologyRule {
366            name: "Zap".to_string(),
367            category: TechnologyCategory::Library(LibraryType::Utility),
368            confidence: 0.85,
369            dependency_patterns: vec!["go.uber.org/zap".to_string()],
370            requires: vec![],
371            conflicts_with: vec![],
372            is_primary_indicator: false,
373            alternative_names: vec![],
374            file_indicators: vec![],
375        },
376        
377        // HTTP CLIENTS
378        TechnologyRule {
379            name: "Resty".to_string(),
380            category: TechnologyCategory::Library(LibraryType::HttpClient),
381            confidence: 0.85,
382            dependency_patterns: vec!["github.com/go-resty/resty".to_string(), "go-resty/resty".to_string()],
383            requires: vec![],
384            conflicts_with: vec![],
385            is_primary_indicator: false,
386            alternative_names: vec!["resty".to_string()],
387            file_indicators: vec![],
388        },
389        
390        // MESSAGING
391        TechnologyRule {
392            name: "NATS".to_string(),
393            category: TechnologyCategory::Library(LibraryType::Utility),
394            confidence: 0.90,
395            dependency_patterns: vec!["github.com/nats-io/nats.go".to_string(), "nats-io/nats.go".to_string()],
396            requires: vec![],
397            conflicts_with: vec![],
398            is_primary_indicator: false,
399            alternative_names: vec!["nats".to_string()],
400            file_indicators: vec![],
401        },
402        TechnologyRule {
403            name: "Kafka".to_string(),
404            category: TechnologyCategory::Library(LibraryType::Utility),
405            confidence: 0.90,
406            dependency_patterns: vec!["github.com/Shopify/sarama".to_string(), "Shopify/sarama".to_string()],
407            requires: vec![],
408            conflicts_with: vec![],
409            is_primary_indicator: false,
410            alternative_names: vec!["sarama".to_string()],
411            file_indicators: vec![],
412        },
413        TechnologyRule {
414            name: "RabbitMQ".to_string(),
415            category: TechnologyCategory::Library(LibraryType::Utility),
416            confidence: 0.90,
417            dependency_patterns: vec!["github.com/streadway/amqp".to_string(), "streadway/amqp".to_string()],
418            requires: vec![],
419            conflicts_with: vec![],
420            is_primary_indicator: false,
421            alternative_names: vec!["amqp".to_string()],
422            file_indicators: vec![],
423        },
424    ]
425}