reddit / emacs

eglot and golang development

JohnDoe365 · 2022-11-21 14:06
I recently switched to eglot. The experience has been pleasant so far. I develop golang. However I am biten by this error message: jsonrpc-error: "request id=249 failed:", (jsonrpc-error-message . "Timed out" I increased eglot and json-rpc timeouts but that doesn't solve the problem. Anoone has experienced this problem? How can I investigate any deeper?
CulturMultur · 2022-11-21 20:16
I have the same problem, and found some gist showing that latest gopls introduced a bug, so downgrade to previous version. I’m not at the keyboard at the moment, later will post details.
JohnDoe365 · 2022-11-21 21:06
That's already very helpful and indeed I did a go install @latest lately. I will try to downgrade.
JohnDoe365 · 2022-11-22 07:11
I stepped back as far as [https://github.com/golang/tools/releases/tag/v0.1.12](https://github.com/golang/tools/releases/tag/v0.1.12) which is of July 2022 and that didn't fix my problem. ​ The only variable I have now is that I upgraded to the latest go where I can't step back because of workspace support. As of now I can't use golang language server and in fact not Emacs at all to develop go as I have code formatting associated with C-x C-s and every command takes \~ 10 seconds to time out.
[deleted] · 2022-11-22 08:11
[deleted]
CulturMultur · 2022-11-22 20:35
Try this please https://github.com/golang/tools/releases/tag/gopls%2Fv0.8.4
JohnDoe365 · 2022-11-23 08:41
Indeed, that works, you saved my day!
CulturMultur · 2022-11-23 13:56
I'm finally at the computer, and here's the post - [https://gist.github.com/sirn/3e37bd4a22d8d30751a139bfd405e4e3](https://gist.github.com/sirn/3e37bd4a22d8d30751a139bfd405e4e3) ​ Edit: I just checked and it doesn't work for me anymore on macOS Ventura and emacs-mac 28.2. Regardless of the gopls version, even v0.8.1 that pointed as safe in the above post. I know for sure, that restarting Mac Book solves it, restarting Emacs doesn't. I think it's something in macOS causing this.
JohnDoe365 · 2022-11-23 16:11
I observed that very small go files (read: func main fmt.Print("Hello World ... ) even work with latest gopls yet bigger go files (> 300 LOC) don't. So I suspect it is an issue within eglot itself. Would be worth inspecting the eglot server communication and the differences which trigger IMHO a problem in eglot itself. Some also suggested that magit (which triggers auto-revert thus file watching) may be somewhow related to this issue. Difference is that if it is working I see the message gopls loading / finished loading packages, and when it's not working, there is no such message i.e. not even a package read attempt message from gopls. I also observed that under some very rare occasions event gopls latest worked regardless of file size and indeed logging out / log in helped to be operational, yet certainly not always. I can't see any pattern in this strange behavior other than the project size is of an issue. ​ Still, I am operational with the version you suggested regardless of the size of the go file itself.
JohnDoe365 · 2022-12-09 13:56
Just for the record: even an older version of gopls now stopped working. Something is totally fishy. Did you manage to get gopls going? Edit: Now I have to work with VSCode, annoying not tobe able to use my favourite editor
JohnDoe365 · 2022-12-11 13:27
Sorry, for being noisy, please see my analysis and "proper" fix: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59883
JohnDoe365 · 2022-12-12 07:49
I have to stop now, but alas it was a Heisenfix - working yesterday, broken today. I think I am suffering of [https://github.com/joaotavora/eglot/issues/587](https://github.com/joaotavora/eglot/issues/587) and [https://github.com/golang/go/issues/54559](https://github.com/golang/go/issues/54559)