mirror of
https://github.com/sstent/sublime-text-3.git
synced 2026-02-05 20:11:58 +00:00
backing up sublime settings
This commit is contained in:
31
Packages/User/linters/go.py
Normal file
31
Packages/User/linters/go.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
from lint import Linter
|
||||
|
||||
def find_files(root, ext):
|
||||
root = root.rstrip(os.sep) + os.sep
|
||||
ret = []
|
||||
for base, dirs, names in os.walk(root):
|
||||
for name in names:
|
||||
if name.endswith(ext):
|
||||
base = base.replace(root, '', 1)
|
||||
ret.append(os.path.join(base, name))
|
||||
return ret
|
||||
|
||||
class Golang(Linter):
|
||||
language = 'go'
|
||||
cmd = ('go', 'build', '-gcflags', '-e -N')
|
||||
regex = r'.+?:(?P<line>\d+): (?P<error>.+)'
|
||||
|
||||
def run(self, cmd, code):
|
||||
code = code.encode('utf8')
|
||||
if not self.filename:
|
||||
tools = self.popen(('go', 'tool')).communicate()[0].split('\n')
|
||||
for compiler in ('6g', '8g'):
|
||||
if compiler in tools:
|
||||
return self.tmpfile(('go', 'tool', compiler, '-e', '-o', os.devnull), code, suffix='.go')
|
||||
else:
|
||||
path = os.path.split(self.filename)[0]
|
||||
os.chdir(path)
|
||||
files = find_files(path, '.go')
|
||||
answer = self.tmpdir(cmd, files, code)
|
||||
return answer
|
||||
Reference in New Issue
Block a user