How to view external go module dependencies in vscode - go

Sometimes I really need to browse and check the code from external dependencies add to my go module.
Although I could CMD+click on the method and vscode editor opens the go file from external dependency, I would really like to see and quickly check other files from the package.
Goland allows this by showing module dependencies.
Is there any way to enable displaying module dependencies in visual studio code?

I'm not sure if this way is as quickly as you want, but after you cmd+Click and reached the external file you can do either of
Navigate all the file through navbar, this way you can check what version of the dependency and you can choose between different version that is available on your module directorey
2. Or you can Copy Path [Ctrl+K Ctrl+Alt+C on linux] then open terminal and do code <file-directory>. It opens a new vscode window on that directory so you can check all the files of the external dependencies.
I know it seems like a lot of step but once you get used to vscode shortcut(copy path, open terminal) i think it's the best we have right now :)

There is no such feature in the oficial Go extension for VS Code, or any extension that provides that as well.
However, there is an open issue https://github.com/golang/vscode-go/issues/2156 in the Go extension. It does not have too many votes (IMO), but it is assigned to a milestone that holds ideas that at least, are on the table to discussion.
Hope this helps

Related

Can I view external Go libraries with VSCode?

I'd like to switch to using VSCode full time, but the one thing keeping me on IntellijIDEA is its ability to view Go standard and all dependency libraries in External Libraries of project which located in $GOROOT or $GOPATH/pkg/mod on the filesystem. In particular, I'd like it to work with Go. As of yet, I've been unable to find a suitable solution to view Go standard and all dependency libraries in the Explorer of VSCode.
You can do this with a few manual steps if you use Workspaces.
Once in a workspace (see link above if unfamiliar with the concept), you can use the GUI (Add folder to workspace) or, what I prefer, the integrated terminal (see example below).
From the integrated terminal:
$ code --add /path/to/"external library"
and the related library will appear in the explorer.
The added paths will be remembered by the workspace on vscode close and restart :-)
Try this plug-in "go mod explorer"

run/debug go application with more then one file on the main package with gogland

I downloaded latest Gogland in order to run/debug Go 1.8.1 applications.
I have the exact problem in Latest Intellij Ultimate EAP.
my project's main package contains several files, when I try to run/debug it as a Go Application, it acts as a Go Single File.
which means that when I try to run the application while choosing the main go file, it complains about missing variables definitions from other files on that same directory that are in the main package as well.
in the Run Configuration when I choose Package instead of File, I can't choose the main package.
so how do I run/debug my project properly ?
thanks! :)
I've created the following video https://youtu.be/ko-wKntCLjg to better demonstrate how to achieve this.
There are two options that are also shows in the video:
the click on the link for adding the ldflags parameter: this is needed for Windows applications in order to allow them to be debugged as well as sometimes in CGO apps (or on OSX) for the same purposes. This is an issue with Go, not the IDE or the the debugger
the second option is the one that says Single instance only. I prefer my run configurations as such since they allow me to run them a single time and press the same shortcut to restart them when needed.
Depending on your operating system or application type, the first one might be needed, while the second one is purely functional for various use-cases (and as I've said, personal preference).
Hope this helps.

How is an ActiveX wrapper created with FireBreath?

I've been through the Windows and Mac video tutorials on the FireBreath (FB) website, through all the documentation and even seen the ActiveX example that a person has provided.
It's been an entire week, but I still can't understand how to create a new project in FB. The only thing explained on the website is how to get the FB sln compiled, where the PluginTest example is already coded. Even for the ActiveX example, only the code is given. It isn't explained as to how they created the project.
So how do I create a new project in FB? Should I just take the existing FB sln file and create a new empty project in it? How do I know what classes I should add to the project? How do I edit cmakeLists.txt to recognize my project? How does running prep2010.cmd make my newly added project compile?
If I need to create a wrapper for my ActiveX, how do I go about creating that project in Windows?
If you have been through the windows video tutorials and didn't see how to create a new project then you were obviously not paying attention. The first video tutorial on both windows and mac tells you how to use fbgen to create a new project.
To get text instructions, you can find them fairly easily:
Go to http://firebreath.org and click on "Getting Started". Scroll down to "Creating a new plugin project" and click on the link.
Either method will walk you through essentially the following steps:
1) Install cmake, visual studio, and python (if you don't have any of them)
2) Get FireBreath (the video tutorials suggest using git; I made the tutorials, so you can guess my suggested method).
3) Run fbgen.py with python and follow the steps.
Congratulations! You have now created a new plugin project!
To build it, you'll need to run the prep script appropriate for your platform and then open the build/FireBreath.(sln | xcodeproj) file in (visual studio | xcode). Note that this differs a bit depending on whether you're on Windows or Mac.
The prep script (such as prep2010.cmd) does not make your project compile; instead it uses cmake to generate the project files for that project for your computer which can then be used to build the project, as explained in the pages linked above. You should never modify anything in the build directory directly, instead you should modify the CMakeLists.txt file in your project directory or if you have platform-specific changes you need to make you can modify Win/projectDef.cmake and Mac/projectDef.cmake.
FireBreath.org is a wiki, so feel free to help us make these things easier to find; as you can see from the links all of the information is there. To me it seems easy to find, so obviously I'm not a good one to try to fix the problem (since I can't see it).
As for making an ActiveX wrapper, there is an example of doing this but it's not really something that is just "easy to do". FireBreath does not in any way attempt to make this a simple thing to do -- that's not the purpose of FireBreath. FireBreath is simply a framework for creating browser plugins; if you want your plugin to act as an activex wrapper you'll have to implement all of the activex for containing your control yourself.
Hopefully that's enough information to get you started. If you are confused, please go read those links. If you're still confused, read them again -- all of this information is there. If you're still confused, come ask in the FireBreath chat room on IRC and I'll try to help you figure it out.

Code::Blocks cannot find function declarations or definitions

Codeblocks cannot find definitions or declarations of some functions in my project.
Question: Is there a way to force a re-scan of the source tree?
I believe that all of the relevant files are included into the project.
(Just checked: it cannot find by name a struct declared in an opened file.)
First, let me give a couple of ways to help C::B find your declarations/definitions.
Although somewhat obvious, you should make sure the function is in a file that is either:
1) part of the project itself (i.e. it should be shown in the projects->workspace window). If you intended it to be part of the project but it isn't there, then go to project->add files and add the file.
2) If you don't want/need the file to be part of the project but you still want to access the declarations/definitions, you need to let the project manager know where to find the file. You can do this in project->build options and set the search directories. Be careful when setting the search directories...you can set it for the whole project or build target (debug or executable).
Note: one common problem occurs when you have multiple projects open in C::B. Even though all your projects are "open", there is only one that is "activated". So, just because you have a file open, it doesn't mean the file is part of the activated project. You can do search-->open files" which will find code in a file if it's open but not in the current active project.
The only way to "re-scan", is to rebuild your project after making changes in the source code or project settings. You may have to restart C::B. If you still can't find the declaration/definition after doing the above, I would suggest you make a sample program and see if it will find the declaration/definition. If it does, then you can check the settings between your project and the sample project. In the worst case, you can copy your code from your project to the sample project. If that doesn't work, you can reinstall C::B and try again. Not fun but sometimes it works.
You can try, rebuilding the project, but make sure at least one other file includes the header for the structure or make sure the header and source file are included in the project.

Changing the default Source File Directory in Visual Studio

This is not a work-stopper in any way, but I thought I should ask anyway because it is a little annoying. Let's say I create a new project and start putting source files in a directory other than the default that shows up the first time. Afterwords, whenever I open the project, I have to navigate to the source directory once during that session. Like I said, not a big deal (but if solvable, then it's icing on the cake). Quite a few times I absentmindedly put the source file in the default directory and end up committing that file to the SVN and if I am lucky, going through all the files, removing them, then adding them again.
So my question is, is there any way to specify the default source directory on a per project basis?
I have run into the same nuisance. I like to put the public interface header files for a library in a separate directory, but end up with file directory typos because I forget to navigate to the correct directory when saving a new file. Unfortunately, Visual Studio does not offer a setting to change the default directory for new C++ source files.
I had the same problem when I started using build systems (CMake, Premake) which requires me to keep my project files separate from my source files, which hampered my workflow.
Although changing the default source directory seems impossible, if you aren't afraid to spend money, the workaround I found was to use the Visual Assist extension.
You can bind a shortcut of your choise to the Create File command which creates
a new file relative to the directory or your open file.
I'd also recommend to base one's workflow around the wonderful
Create from Usage command (which I think greatly boosts
productivity) which almost eliminates the need to manually create files.
The extension is great, albeit a bit costly. I would love to see Microsoft incorporate these features directly in the IDE eventually as they are found vanilla in a lot of other IDEs e.g. Eclipse, Intellij.
There might be some free extensions available that does the same thing, but I haven't found any.
Changing the Default Project Folder may help. This page demonstrates how to change the default for Visual Studio 2005, and it should be the same for later versions.

Resources