Closed malkhamis closed 5 years ago
Are you synced to the most recent version? I'm not able to reproduce this.
I did clone master and ensured that gocode
is not running.. I then ran go install
while being inside master. If you are unable to reproduce this, then I will suspect that this is an Atom/Go-Plus issue
@malkhamis go-plus uses mdempsky/gocode by default - just wanted to confirm, have you explicitly installed this fork?
@zmb3 I performed the following steps to ensure that this fork is used:
$ gocode exit
$ rm ~/go/bin/gocode
$ gocode
> bash: gocode: command not found...
$ rm -rf ~/go/src/github.com/stamblerre/
$ mkdir ~/go/src/github.com/stamblerre/
$ cd ~/go/src/github.com/stamblerre/
$ git clone git@github.com:stamblerre/gocode.git
$ go install ./...
$ gocode -s -debug
Now when I type code in Atom, I observe an output from gocode
and everything is fine. This is until I insert a comment in the following line, I get autocompletion suggestions for symbols in the file, but once I type symbol.
(i.e. .
), the gocode output stops altogether. Things are okay after I remove the comment I inserted in the following line
@malkhamis: can you try this in an another editor to confirm that the bug is in Atom? I was not able to reproduce using VSCode.
I cannot reproduce this in Atom either.
2018/12/17 15:41:55 Got autocompletion request for '/Users/zmb3/complete/main.go'
2018/12/17 15:41:55 Cursor at: 48
2018/12/17 15:41:55 -------------------------------------------------------
package main
import "fmt"
func main() {
fmt.#
//comment
}
2018/12/17 15:41:55 -------------------------------------------------------
2018/12/17 15:41:55 error in package github.com/zmb3/complete: /Users/zmb3/complete/main.go:6:7:_ not declared by package fmt
2018/12/17 15:41:55 Elapsed duration: 210.343033ms
2018/12/17 15:41:55 Offset: 0
2018/12/17 15:41:55 Number of candidates found: 25
2018/12/17 15:41:55 Candidates are:
2018/12/17 15:41:55 func Errorf(format string, a ...interface{}) error
2018/12/17 15:41:55 func Fprint(w io.Writer, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Fprintln(w io.Writer, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Fscan(r io.Reader, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Fscanln(r io.Reader, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Print(a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Printf(format string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Println(a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Scan(a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Scanf(format string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Scanln(a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Sprint(a ...interface{}) string
2018/12/17 15:41:55 func Sprintf(format string, a ...interface{}) string
2018/12/17 15:41:55 func Sprintln(a ...interface{}) string
2018/12/17 15:41:55 func Sscan(str string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Sscanf(str string, format string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 func Sscanln(str string, a ...interface{}) (n int, err error)
2018/12/17 15:41:55 type Formatter interface
2018/12/17 15:41:55 type GoStringer interface
2018/12/17 15:41:55 type ScanState interface
2018/12/17 15:41:55 type Scanner interface
2018/12/17 15:41:55 type State interface
2018/12/17 15:41:55 type Stringer interface
2018/12/17 15:41:55 =======================================================
@stamblerre
I couldn't reproduce this in VSCode either... However, I noticed that vscode would successfully autocomplete albeit I see no output in the terminal while gocode -s --debug
is running. I am not a vscode user, so I am unsure if vscode runs multiple autocompletion daemons/process/programs and tries to intelligently autocomplete with best effort?
@zmb3 After trying vscode, it asked me to install stamblerre/gocode and I noticed a binary called gocode-gomod
in my GOPATH/bin.. I tried to delete the gocode
binary in there and rename the gocode-gomod
binary to gocode
... I than ran it in terminal in debug mode... I could observe autocompletion requests from Atom, but the same behavior exists (i.e. no autocompletion beyond what is in the current file if the next line is a comment) :(
VSCode runs mdempsky/gocode when users are not in module mode, and it runs this version of gocode, renamed to gocode-gomod
to avoid conflicts, in module mode. I'm really unable to reproduce this issue, as you can see from the debug output below.
2018/12/20 13:01:24 Got autocompletion request for '/usr/local/google/home/rstambler/Desktop/gocodetest/main.go'
2018/12/20 13:01:24 Cursor at: 123
2018/12/20 13:01:24 -------------------------------------------------------
package main
import (
"fmt"
"rsc.io/quote"
)
func main() {
fmt.Println("hello")
quote.Hello()
quote.Hello()
quote.#Glass()
}
2018/12/20 13:01:24 -------------------------------------------------------
2018/12/20 13:01:24 error in package github.com/stamblerre/gocodetest: /usr/local/google/home/rstambler/Desktop/gocodetest/main.go:13:8:_ not declared by package quote
2018/12/20 13:01:24 Elapsed duration: 113.23792ms
2018/12/20 13:01:24 Offset: 0
2018/12/20 13:01:24 Number of candidates found: 4
2018/12/20 13:01:24 Candidates are:
2018/12/20 13:01:24 func Glass() string
2018/12/20 13:01:24 func Go() string
2018/12/20 13:01:24 func Hello() string
2018/12/20 13:01:24 func Opt() string
2018/12/20 13:01:24 =======================================================
2018/12/20 13:01:34 Got autocompletion request for '/usr/local/google/home/rstambler/Desktop/gocodetest/main.go'
2018/12/20 13:01:34 Cursor at: 123
2018/12/20 13:01:34 -------------------------------------------------------
package main
import (
"fmt"
"rsc.io/quote"
)
func main() {
fmt.Println("hello")
quote.Hello()
quote.Hello()
quote.#Glass()
//hello
}
2018/12/20 13:01:34 -------------------------------------------------------
2018/12/20 13:01:34 error in package github.com/stamblerre/gocodetest: /usr/local/google/home/rstambler/Desktop/gocodetest/main.go:13:8:_ not declared by package quote
2018/12/20 13:01:34 Elapsed duration: 104.063464ms
2018/12/20 13:01:34 Offset: 0
2018/12/20 13:01:34 Number of candidates found: 4
2018/12/20 13:01:34 Candidates are:
2018/12/20 13:01:34 func Glass() string
2018/12/20 13:01:34 func Go() string
2018/12/20 13:01:34 func Hello() string
2018/12/20 13:01:34 func Opt() string
2018/12/20 13:01:34 =======================================================
2018/12/20 13:02:53 Got autocompletion request for '/usr/local/google/home/rstambler/Desktop/gocodetest/main.go'
2018/12/20 13:02:53 Cursor at: 144
2018/12/20 13:02:53 -------------------------------------------------------
package main
import (
"fmt"
"rsc.io/quote"
)
func main() {
fmt.Println("hello")
quote.Hello()
quote.Hello()
quote.Glass()
//hello
}
q#
// hello
2018/12/20 13:02:53 -------------------------------------------------------
2018/12/20 13:02:53 error in package github.com/stamblerre/gocodetest: /usr/local/google/home/rstambler/Desktop/gocodetest/main.go:4:2:"fmt" imported but not used
2018/12/20 13:02:53 error in package github.com/stamblerre/gocodetest: /usr/local/google/home/rstambler/Desktop/gocodetest/main.go:6:2:"rsc.io/quote" imported but not used
2018/12/20 13:02:53 Elapsed duration: 131.963793ms
2018/12/20 13:02:53 Offset: 0
2018/12/20 13:02:53 Number of candidates found: 1
2018/12/20 13:02:53 Candidates are:
2018/12/20 13:02:53 package quote
2018/12/20 13:02:53 =======================================================
2018/12/20 13:02:54 Got autocompletion request for '/usr/local/google/home/rstambler/Desktop/gocodetest/main.go'
2018/12/20 13:02:54 Cursor at: 149
2018/12/20 13:02:54 -------------------------------------------------------
package main
import (
"fmt"
"rsc.io/quote"
)
func main() {
fmt.Println("hello")
quote.Hello()
quote.Hello()
quote.Glass()
//hello
}
quote.#
// hello
2018/12/20 13:02:54 -------------------------------------------------------
2018/12/20 13:02:54 error in package github.com/stamblerre/gocodetest: /usr/local/google/home/rstambler/Desktop/gocodetest/main.go:4:2:"fmt" imported but not used
2018/12/20 13:02:54 error in package github.com/stamblerre/gocodetest: /usr/local/google/home/rstambler/Desktop/gocodetest/main.go:6:2:"rsc.io/quote" imported but not used
2018/12/20 13:02:54 Elapsed duration: 126.898834ms
2018/12/20 13:02:54 Offset: 0
2018/12/20 13:02:54 Number of candidates found: 4
2018/12/20 13:02:54 Candidates are:
2018/12/20 13:02:54 func Glass() string
2018/12/20 13:02:54 func Go() string
2018/12/20 13:02:54 func Hello() string
2018/12/20 13:02:54 func Opt() string
2018/12/20 13:02:54 =======================================================
OK I guess I am the only affected by this for some reason.. I will close this issue then. Thanks a lot for your followup.. really appreciate it
Sorry, I wasn't able to help! I guess my best advice would be to make sure you're synced to head and maybe rebuild it - try go get -u github.com/stamblerre/gocode
?
What version of Go are you using (
go version
)?1.11
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64" GOBIN="" GOCACHE="/home//.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home//go" GOPROXY="" GORACE="" GOROOT="/usr/lib/golang" GOTMPDIR="" GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home//src/github.com//***/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build102471124=/tmp/go-build -gno-record-gcc-switches"
What is the debug output of
gocode
?None
What (client-side) flags are you passing into
gocode
?potentially
-f=json
andautocomplete
via Go-Plus plugin in Atom?What editor are using?
Atom
The Problem
Autocompletion works flawlessly except for the case in which the next line starts with
// comment
or/* comment */
. Thus, autocompletion does not work if the code looks like this:However, this works: