is is possible to use Revel framework with Go code completion support. As far as i know the gocode
utility requires the code to be compiled into a library into a pkg subfolder in order to function, but the framework does compilation on the fly.
I am kind of lost on the topic. Would the proper way be calling the go install for relevant subpackages? That seems to work but it is not the most elegant way of doing this from my perspective.
Hope that someone can point me in right direction.
EDIT: the problem is focused only on sources that I write as part of my Revel application. Downloaded packages have autocompletion as expected
EDIT2: This is the best solution I have found so far - executing go get
command on your project's app/tmp
subfolder. So if your project is called my_project then you would call something like go get my_project/revel/app/tmp
Because this folder contains the main function for the project, it will pull all the dependencies and build them into packages. If the tmp folder does not exist you have to do revel run
on your project and open your web app so it gets created on the fly. Hope this helps at least a bit. I am still open for a better alternative :)
You revel application needs to reside inside of your $GOPATH/src folder and then code completion will work for your web app.
Either the process of compilation by Revel's harness
has changed or gocode
has been improved. But everything works now out of the box. No additional efforts are required.
I have faced the same problem. My solution is a modified version of your EDIT 2 workaround. In my app/init.go
I added:
import "os/exec"
and
// Build the project packages on app start so it's possible to use autocomplete.
revel.OnAppStart(func() {
if revel.Config.BoolDefault("mode.dev", false) {
go func() {
_, err := exec.Command("go", "get", "bitbucket.org/USERNAME/PROJECT/app/tmp").Output()
if err != nil {
revel.ERROR.Printf("failed to 'go get' project, error: %v", err)
}
}()
}
})
So, now in dev mode it automatically recompiles all the packages on every recompilation of revel project.