This is really a placeholder issue following discussion with @ianthehat on Slack.
In various govim integration tests, I am having to insert "waits" in order to be sure gopls can handle a particular request.
Consider the following sequence:
Open Vim (which loads govim, which starts gopls, calls Initialize, calls Initialized)
Open main.go (which results in didOpen notification to gopls)
Move cursor to known position
Note: all of the above steps are sequential.
If these steps happen quickly, the triggering of go-to-def can happen before gopls is "ready". This results in a response along the lines of "don't know anything about identifier under cursor".
As a workaround, I am waiting for diagnostics to be sent for main.go before triggering the go-to-def.
However, I think this should really be an implementation detail of gopls. i.e. when the call to go-to-def comes in, any pending notifications should be handled, processed etc in such a way that if any is relevant to the subsequent go-to-def call they must be handled before the call (because the events themselves happened before).