为什么本地软件包的自动完成功能不能在Atom编辑器中工作?
Autocomplete (go-plus) works fine in Atom for standard library imports, but whenever I try to import my own packages It simply doesn't work.
My package structure goes like this:
.
├── bin
├── pkg
└── src
└── Test
├── MyPackage
│ └── hello.go
└── main.go
main.go
package main
import (
"Test/MyPackage"
)
func main() {
hello.SayHello("World")
}
hello.go
package hello
import "fmt"
const Msg = "Hello "
func SayHello(name string) {
fmt.Printf("%v%v!
", Msg, name)
}
The file compiles fine, but in main.go
the hello
package does not invoke any autocompletion in Atom, so what could be the problem?
自动完成(go-plus)在Atom中对于标准库导入工作正常,但是每当我尝试导入自己的包时 它根本不起作用。 p>
我的软件包结构如下: p>
。
├──bin
├──pkg
└── src
└──测试
├──MyPackage
│└──hello.go
└──main.go
code> pre>
main.go strong> p>
程序包main
import(
“ Test / MyPackage”
)
func main(){
你好。 的SayHello( “世界”)\ N}
代码> PRE>
hello.go 强> p>
包hello
import“ fmt”
const Msg =“ Hello”
func SayHello(名称字符串){
fmt.Printf(“%v%v!
”,Msg,name)
}
code> pre>
文件可以正常编译,但是在 main.go code>中, hello code>包不会调用任何自动完成功能 在Atom中,那么可能是什么问题? p>
div>
The issue is addressed in the README.md of the go-plus package:
First of all, make sure autocomplete-plus is present on your setup. Go-plus provides autocompletion through gocode tool, so you should ensure it's in PATH and available.
If you can't get autocompletion for the user-defined packages working, while it's there for packages from standard library, it's likely a trivial gocode-related issue. Try running
gocode set
. Some expected output'd be:propose-builtins false lib-path "" autobuild false force-debug-output "" package-lookup-mode "go"
What you gotta do is switching autobuild to true, by running
gocode set autobuild true
. Check autocompletion now, it must be working right.
Another possible cause is the gocode
daemon is not working properly (either it is due to an update of Go or multiple gocode
daemons). Closing the daemon may help.
gocode close