This commit is contained in:
Liang Ding 2014-09-15 09:52:36 +08:00
parent abd1a8e9c0
commit e398438e60
4 changed files with 21 additions and 14 deletions

View File

@ -46,7 +46,7 @@ A simple <b>W</b>eb **IDE** for golang.
## Setup from sources
1. Downloads source
2. Gets dependencies with `go get -u`
2. Gets dependencies with `go get -u`, `go get -u github.com/88250/ide_stub` and `go get -u github.com/nsf/gocode`
3. Compiles wide with `go build`
4. Configures `conf/wide.json`
5. Runs the executable `wide` or `wide.exe`

View File

@ -32,9 +32,14 @@
步骤:
<ol>
<li>通过 git clone 或下载 zip 包方式获取 Wide 源码(项目地址:<a href="https://github.com/b3log/wide">https://github.com/b3log/wide</a></li>
<li>获取 Wide 依赖go get -u</li>
<li>编译 Widego build</li>
<li>通过 <code>git clone</code> 或下载 zip 包方式获取 Wide 源码(项目地址:<a href="https://github.com/b3log/wide">https://github.com/b3log/wide</a></li>
<li>获取依赖,在 Wide 源码目录下执行:
<ul>
<li><code>go get -u</code></li>
<li><code>go get -u github.com/88250/ide_stub</code></li>
<li><code>go get -u github.com/nsf/gocode</code></li>
</ul>
<li>编译:在 Wide 源码目录下执行 <code>go build</code></li>
<li>配置 {wide}/conf/<a href="conf.html">wide.json</a>(可选,默认配置应该可以工作)</li>
<li>运行可执行文件 wide 或 wide.exe</li>
</ol>

View File

@ -62,11 +62,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
// glog.Infof("offset: %d", offset)
gocode := os.Getenv("GOPATH") + string(os.PathSeparator) +
os.Getenv("OS") + string(os.PathSeparator) + os.Getenv("GOARCH") + string(os.PathSeparator) + "gocode"
argv := []string{"-f=json", "autocomplete", strconv.Itoa(offset)}
var output bytes.Buffer
cmd := exec.Command("gocode", argv...)
cmd := exec.Command(gocode, argv...)
cmd.Stdout = &output
stdin, _ := cmd.StdinPipe()
@ -118,8 +120,10 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
//glog.Infof("gocode set lib-path %s", libPath)
// FIXME: 使用 gocode set lib-path 在多工作空间环境下肯定是有问题的,需要考虑其他实现方式
gocode := os.Getenv("GOPATH") + string(os.PathSeparator) +
os.Getenv("OS") + string(os.PathSeparator) + os.Getenv("GOARCH") + string(os.PathSeparator) + "gocode"
argv := []string{"set", "lib-path", libPath}
cmd := exec.Command("gocode", argv...)
cmd := exec.Command(gocode, argv...)
cmd.Start()
//gocode 试验性质特性:自动构建
@ -128,7 +132,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
//cmd.Start()
argv = []string{"-f=json", "autocomplete", strconv.Itoa(offset)}
cmd = exec.Command("gocode", argv...)
cmd = exec.Command(gocode, argv...)
stdin, _ := cmd.StdinPipe()
stdin.Write([]byte(code))
@ -194,8 +198,10 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
// glog.Infof("offset [%d]", offset)
// TODO: 目前是调用 liteide_stub 工具来查找声明,后续需要重新实现
ide_stub := os.Getenv("GOPATH") + string(os.PathSeparator) +
os.Getenv("OS") + string(os.PathSeparator) + os.Getenv("GOARCH") + string(os.PathSeparator) + "ide_stub"
argv := []string{"type", "-cursor", filename + ":" + strconv.Itoa(offset), "-def", "."}
cmd := exec.Command("liteide_stub", argv...)
cmd := exec.Command(ide_stub, argv...)
cmd.Dir = curDir
setCmdEnv(cmd, username)
@ -274,10 +280,9 @@ func FindUsagesHandler(w http.ResponseWriter, r *http.Request) {
offset := getCursorOffset(code, line, ch)
// TODO: 目前是调用 liteide_stub 工具来查找使用,后续需要重新实现
argv := []string{"type", "-cursor", filename + ":" + strconv.Itoa(offset), "-use", "."}
ide_stub := os.Getenv("GOPATH") + string(os.PathSeparator) +
os.Getenv("OS") + string(os.PathSeparator) + os.Getenv("GOARCH") + string(os.PathSeparator) + "ide_stub"
argv := []string{"type", "-cursor", filename + ":" + strconv.Itoa(offset), "-use", "."}
cmd := exec.Command(ide_stub, argv...)
cmd.Dir = curDir

View File

@ -16,9 +16,6 @@ import (
"github.com/b3log/wide/shell"
"github.com/b3log/wide/user"
"github.com/golang/glog"
_ "github.com/88250/ide_stub" // 运行时依赖,用于跳转到声明、查找使用等功能
_ "github.com/nsf/gocode" // 运行时依赖,用于代码自动完成
)
// Wide 中唯一一个 init 函数.