deoplete-go doesn't work on named package import
ntcong opened this issue · 3 comments
Today I used "logrus" and noticed that if I import as logrus, completion works fine, but if I import it as log, completion doesn't work.
https://asciinema.org/a/29vcn2nzjyhf13s4wlm1lvsb6
Tried to debug gocode, but it does found some candidates
package main
import log "github.com/Sirupsen/logrus"
func main() {
log.Info("test")
log.#
}
2017/02/09 21:03:00 -------------------------------------------------------
2017/02/09 21:03:00 Found "github.com/Sirupsen/logrus" at "workspace/go/pkg/darwin_amd64/github.com/Sirupsen/logrus.a"
2017/02/09 21:03:00 Error parsing input file (inner block):
2017/02/09 21:03:00 5:6: expected selector or type assertion, found ';'
2017/02/09 21:03:00 extracted expression tokens: log
2017/02/09 21:03:00 Offset: 0
2017/02/09 21:03:00 Number of candidates found: 65
2017/02/09 21:03:00 Candidates are:
2017/02/09 21:03:00 const DebugLevel
2017/02/09 21:03:00 const DefaultTimestampFormat
2017/02/09 21:03:00 const ErrorLevel
2017/02/09 21:03:00 const FatalLevel
2017/02/09 21:03:00 const FieldKeyLevel
2017/02/09 21:03:00 const FieldKeyMsg
2017/02/09 21:03:00 const FieldKeyTime
2017/02/09 21:03:00 const InfoLevel
2017/02/09 21:03:00 const PanicLevel
2017/02/09 21:03:00 const WarnLevel
2017/02/09 21:03:00 func AddHook(hook #logrus.Hook)
2017/02/09 21:03:00 func Debug(args ...interface{})
2017/02/09 21:03:00 func Debugf(format string, args ...interface{})
2017/02/09 21:03:00 func Debugln(args ...interface{})
2017/02/09 21:03:00 func Error(args ...interface{})
2017/02/09 21:03:00 func Errorf(format string, args ...interface{})
2017/02/09 21:03:00 func Errorln(args ...interface{})```
So I figured out that I enabled let g:deoplete#sources#go#use_cache = 1
. Because I used both go's log package and logrus as log, so maybe there are some duplicate key in the cache function. Disable use_cache fixes the problem
I think this is pretty bad behavior and should be documented
@ntcong Ah, OK. I totally understand this situation.
Now I do not test, but I think maybe will the same result. It's a bug. Sorry for confused.
But historically, g:deoplete#sources#go#use_cache
was for non-imported package completion.
But after the while, the gocode same feature has been added. So currently almost not necessary (if you want to get completion that third-party package with non-imported, still can use it).
However, Now gocode has a small bug that not supported duplicated package name. such as go/scanner
and text/scanner
. I planned fix gocode core, and after that, finally I remove use_cache
feature from deoplete-go.
But yeah, use_cache
a bit buggy. So sorry, Please disable it and use gocode
original's non-imported feature.
Now I am developing support the type alias feature on gocode
(See nsf/gocode #417). If I finished that, I'll fix "duplicated package name" bug. Please wait a moment.
I have removed the cache feature.