MCPcopy Create free account
hub / github.com/diillson/chatcli / DetectFileType

Function DetectFileType

utils/file_utils.go:69–118  ·  view source on GitHub ↗

DetectFileType detecta o tipo de arquivo com base na extensão

(filePath string)

Source from the content-addressed store, hash-verified

67
68// DetectFileType detecta o tipo de arquivo com base na extensão
69func DetectFileType(filePath string) string {
70 fileTypes := map[string]string{
71 ".go": "Go",
72 ".tf": "Terraform",
73 ".py": "Python",
74 ".js": "JavaScript",
75 ".ts": "TypeScript",
76 ".jsx": "React JSX",
77 ".tsx": "React TSX",
78 ".java": "Java",
79 ".c": "C",
80 ".cpp": "C++",
81 ".h": "C Header",
82 ".hpp": "C++ Header",
83 ".cs": "C#",
84 ".rb": "Ruby",
85 ".php": "PHP",
86 ".html": "HTML",
87 ".css": "CSS",
88 ".scss": "SCSS",
89 ".less": "LESS",
90 ".json": "JSON",
91 ".xml": "XML",
92 ".yaml": "YAML",
93 ".yml": "YAML",
94 ".md": "Markdown",
95 ".txt": "Text",
96 ".sql": "SQL",
97 ".sh": "Shell",
98 ".bash": "Bash",
99 ".zsh": "ZSH",
100 ".env": "Environment",
101 ".toml": "TOML",
102 ".ini": "INI",
103 ".config": "Config",
104 ".rs": "Rust",
105 ".dart": "Dart",
106 ".swift": "Swift",
107 ".kt": "Kotlin",
108 ".groovy": "Groovy",
109 ".scala": "Scala",
110 ".pl": "Perl",
111 ".pm": "Perl Module",
112 }
113 ext := strings.ToLower(filepath.Ext(filePath))
114 if fileType, ok := fileTypes[ext]; ok {
115 return fileType
116 }
117 return "Text"
118}
119
120// matchesAny verifica se uma string corresponde a algum dos padrões fornecidos
121func matchesAny(s string, patterns []string) bool {

Callers 2

ProcessDirectoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected