mdempsky / gocode

An autocompletion daemon for the Go programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No auto-complete with type-assertions

zimmski opened this issue · comments

What version of Go are you using (go version)?

1.11.4

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="amd64"
GOHOSTOS="linux"

What is the debug output of gocode?

I added the suggested arguments but then gocode does not work at all for me in VS.Code. The settings I used were:

"go.gocodeFlags": [
		"-builtin",
		"-ignore-case",
		"-unimported-packages",
		"-s",
		"-debug"
	],

What editor are using?

VS.Code 1.31.1


It seems that gocode needs paranthesis around type assertions to show its auto-completion.

The following code shows me the menu when I type the dot:

package main

type Message struct {
	Data string
}

func main() {
	var p interface{} = &Message{
		Data: "hello fellow",
	}

	_ = (p.(*Message)).
}

The following code does not:

package main

type Message struct {
	Data string
}

func main() {
	var p interface{} = &Message{
		Data: "hello fellow",
	}

	_ = p.(*Message).
}

@zimmski: sorry, it looks like the 2 blocks of code you posted are the same - what's the actual failing case?

@stamblerre sorry I "miscopied" (I already modified the issue's description). If I do the type assertion like this _ = p.(*Message). there is no auto-complete menu in VS.Code.

@stamblerre please let me know if you need anything else.

I just confirmed that gopls does handle this case, so I would suggest using it for a better Go autocompletion experience. This repository is in maintenance mode, so I will not be able to make any improvements here.