Skip to content

Commit d5fa4d4

Browse files
committed
Check Go version using vim.system
1 parent 17278db commit d5fa4d4

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

lua/gitlab/version.lua

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
local M = {}
22

33
M.is_go_valid = function()
4-
local go_version = io.popen("go version 2>&1"):read("*a")
5-
if go_version then
6-
local major, minor, _ = go_version:match("(%d+)%.(%d+)%.?(%d*)")
7-
if major and tonumber(major) >= 1 and tonumber(minor) >= 25 then
8-
return true
9-
else
10-
return false
11-
end
4+
local has_go, go = pcall(vim.system, {"go", "version"});
5+
if not has_go then
6+
return false
7+
end
8+
9+
local go_version = go:wait().stdout;
10+
local major, minor, _ = go_version:match("(%d+)%.(%d+)%.?(%d*)")
11+
if major and tonumber(major) >= 1 and tonumber(minor) >= 25 then
12+
return true
1213
else
1314
return false
1415
end

0 commit comments

Comments
 (0)