detect go.mod files as Go language
This commit is contained in:
parent
d11c64db2b
commit
4c4760a805
3 changed files with 10 additions and 0 deletions
0
tests/samples/codefiles/go.mod
Normal file
0
tests/samples/codefiles/go.mod
Normal file
|
@ -274,3 +274,9 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
expected_language='JavaScript',
|
expected_language='JavaScript',
|
||||||
entity='javascript_module.mjs',
|
entity='javascript_module.mjs',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_go_mod_detected(self):
|
||||||
|
self.shared(
|
||||||
|
expected_language='Go',
|
||||||
|
entity='go.mod',
|
||||||
|
)
|
||||||
|
|
|
@ -169,6 +169,10 @@ def get_language_from_extension(file_name):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filepart, extension = os.path.splitext(file_name)
|
filepart, extension = os.path.splitext(file_name)
|
||||||
|
pathpart, filename = os.path.split(file_name)
|
||||||
|
|
||||||
|
if filename == 'go.mod':
|
||||||
|
return 'Go'
|
||||||
|
|
||||||
if re.match(r'\.h.*$', extension, re.IGNORECASE) or re.match(r'\.c.*$', extension, re.IGNORECASE):
|
if re.match(r'\.h.*$', extension, re.IGNORECASE) or re.match(r'\.c.*$', extension, re.IGNORECASE):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue