4 Star 6 Fork 2

smark / gorun

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gorun.py 941 Bytes
一键复制 编辑 原始数据 按行查看 历史
smark 提交于 2013-10-27 22:00 . init commit
# -*- coding: utf-8 -*-
import sublime, sublime_plugin,os
# run go program
class GorunCommand(sublime_plugin.TextCommand):
def run(self, edit):
#self.view.insert(edit, 0, "Hello, World!")
fname =str(self.view.file_name())
tmp = fname.rfind('/')
if tmp<0:
tmp = fname.rfind('\\')
tmpfile = fname[0:tmp+1]+"tmp.txt"
cm = "go run " + fname + " >"+tmpfile
print "[execute]:"+cm
os.system(str(cm))
txt = str("")
file_object = open(tmpfile)
try:
txt = file_object.read( )
finally:
file_object.close( )
print txt
os.remove(tmpfile)
# format the current file of go
class GofmtCommand(sublime_plugin.TextCommand):
def run(self, edit):
#self.view.insert(edit, 0, "Hello, World!")
fname =str(self.view.file_name())
cm = "go fmt "+ fname
print "[execute]:"+cm
#print self.view.window().open_file(fname)
#os.system(str(cm))
print "hello"
self.view.run_command("revert")
Python
1
https://gitee.com/smark/gorun.git
git@gitee.com:smark/gorun.git
smark
gorun
gorun
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891