Skip to content
This repository was archived by the owner on Oct 9, 2021. It is now read-only.

Commit 4c4760a

Browse files
committed
detect go.mod files as Go language
1 parent d11c64d commit 4c4760a

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

tests/samples/codefiles/go.mod

Whitespace-only changes.

tests/test_languages.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,9 @@ def test_mjs_javascript_module_extension_detected(self):
274274
expected_language='JavaScript',
275275
entity='javascript_module.mjs',
276276
)
277+
278+
def test_go_mod_detected(self):
279+
self.shared(
280+
expected_language='Go',
281+
entity='go.mod',
282+
)

wakatime/stats.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ def get_language_from_extension(file_name):
169169
"""
170170

171171
filepart, extension = os.path.splitext(file_name)
172+
pathpart, filename = os.path.split(file_name)
173+
174+
if filename == 'go.mod':
175+
return 'Go'
172176

173177
if re.match(r'\.h.*$', extension, re.IGNORECASE) or re.match(r'\.c.*$', extension, re.IGNORECASE):
174178

0 commit comments

Comments
 (0)