package linter import "strings" // DetectPrimaryLanguage returns the dominant language from the list of files. // It counts detected languages and returns the most frequent one. // Falls back to "go" (common default) or "unknown". func DetectPrimaryLanguage(files []string) string { if len(files) == 0 { return "unknown" } counts := make(map[string]int) for _, file := range files { lang, err := DetectLanguage(file) if err == nil && lang != nil { name := strings.ToLower(lang.Name) counts[name]++ } } if len(counts) == 0 { return "unknown" } // Find most common language var bestLang string maxCount := -1 for lang, count := range counts { if count > maxCount { maxCount = count bestLang = lang } } // Bias toward Go in mixed repos if counts["go"] > 0 && counts["go"] >= maxCount/2 { return "go" } return bestLang } // SupportedLanguages returns all known languages (for future use or error messages). func SupportedLanguages() []string { var langs []string for _, l := range languages { langs = append(langs, strings.ToLower(l.Name)) } return langs }