This commit is contained in:
parent
abd1a8e9c0
commit
e398438e60
|
@ -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`
|
||||
|
|
|
@ -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>编译 Wide:go 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>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue