diff --git a/README.md b/README.md index 09f333c..32b71d1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ A simple Web **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` diff --git a/doc/zh_CN/setup.html b/doc/zh_CN/setup.html index 6541a16..c91dd8d 100644 --- a/doc/zh_CN/setup.html +++ b/doc/zh_CN/setup.html @@ -32,11 +32,16 @@ 步骤:
    -
  1. 通过 git clone 或下载 zip 包方式获取 Wide 源码(项目地址:https://github.com/b3log/wide
  2. -
  3. 获取 Wide 依赖:go get -u
  4. -
  5. 编译 Wide:go build
  6. +
  7. 通过 git clone 或下载 zip 包方式获取 Wide 源码(项目地址:https://github.com/b3log/wide
  8. +
  9. 获取依赖,在 Wide 源码目录下执行: + +
  10. 编译:在 Wide 源码目录下执行 go build
  11. 配置 {wide}/conf/wide.json(可选,默认配置应该可以工作)
  12. -
  13. 运行可执行文件 wide 或 wide.exe
  14. +
  15. 运行可执行文件 wide 或 wide.exe
diff --git a/editor/editors.go b/editor/editors.go index d0b79f5..58ddd5e 100644 --- a/editor/editors.go +++ b/editor/editors.go @@ -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 diff --git a/main.go b/main.go index 16857e9..85b1032 100644 --- a/main.go +++ b/main.go @@ -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 函数.