Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCODE for golang

I have been using VSCode for programming in Golang and sometimes GoLand trial version. I want to stick with VSCode but I cannot find the below-mentioned capabilities in VSCode. Can anyone tell me if it is possible or not

  • There is no way for me to have a pop-up displaying 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 the list of all implementers?
  • Is there a way to click on a struct and see the list of all interfaces it implements?

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

like image 253
curiousengineer Avatar asked Sep 03 '25 15:09

curiousengineer


1 Answers

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.

Code outline

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.

Interface to implementation

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.

Implementation to interface

like image 58
MichalG Avatar answered Sep 05 '25 15:09

MichalG