detect go.mod files as Go language

This commit is contained in:
Alan Hamlett 2019-03-28 09:31:21 +09:00
parent d11c64db2b
commit 4c4760a805
3 changed files with 10 additions and 0 deletions

View file

View file

@ -274,3 +274,9 @@ class LanguagesTestCase(utils.TestCase):
expected_language='JavaScript',
entity='javascript_module.mjs',
)
def test_go_mod_detected(self):
self.shared(
expected_language='Go',
entity='go.mod',
)

View file

@ -169,6 +169,10 @@ def get_language_from_extension(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):