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?
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