简体   繁体   中英

VSCODE for golang

I have been using VSCode forGolang and sometimes GoLand trial version. I want to stick with VSCode but I cannot find the below things in the plugin. Can anyone tell me if it is possible or not

  • There is no way for me to have a pop-up show up to see the list of all functions, structs, interfaces in the file that I have open?
  • Is there a way to click on an interface and see who all implement it?
  • Is there a way to click on a struct and see what all interfaces it implements?

GoLand has all the 3 and that is what makes it amazing. Other than that most things are similar.

Actually it is possible to do all three things in VS Code as well.

1. List of all functions, structs, interface - Code Outline

There is a great extension Code Outline that works very well with Go code. I'm using it successfully without any problems.

代码大纲

2. Is there a way to click on an interface and see who all implement it?

According to VS Code documentation , it is possible to go to definition using Ctrl + F12 shortcut. It seems to work well for Go source code at this point.

实施接口

3. Is there a way to click on a struct and see what all interfaces it implements?

Similarly as with answer above, and according to documentation, Ctrl + F12 shortcut seems to be working well in that case.

For an interface, this shows all the implementors of that interface and for abstract methods, this shows all concrete implementations of that method.

实现接口

Just right click on interface/struct definition and select " Go to implementations ", it will pop up an context window.

Internally it relies on guru which had been deprecated by golang team. Guru does not support module as well.

Newer plugin gopls relies on " Language Server Protocol(LSP) " which is actively developing by golang team, but I am not sure it has same functionality as "Go to implementations".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM