Setting up Development environment for VSCode

I’m trying to setup a debug/development environment so I can start contributing. I have installed all the dependencies, cloned the repository and successfully compiled. I’m editing in VSCode as I’m familiar with this IDE and have used it extensively for Python. The debugging capability with breakpoints and watches is decent, and for me, trying to figure out how Syncthing works, inspecting variable state and tracing is kind-of important…

I can launch my source code (which is verbatim as cloned at the moment) and everything works. I can set breakpoints in main.go and those breakpoints function. however, if I set breakpoints elsewhere, the red dots turn to hollow grey circles indicating that VSCode can’t stop execution and the breakpoints never trip.

I’m aware of the monitor process, and I’ve set the environment variable so the monitor process shouldn’t be running, and I should be debugging the code in one process. But it’s not working. Anyone have any clue how to setup the VSCode environment on windows to make this work?

Here’s the launch.json I’m using:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}\\cmd\\syncthing",
            "env": { "STMONITORED":"yes" },
            "args": ["serve","--home=C:\\Users\\micha\\AppData\\Local\\SyncthingDEV","--paused","--no-upgrade","--gui-address=http://localhost:9090"]
        }
    ]   
}

Here, the environment variable is working and the monitor process is not chosen.

Has anyone setup a good development environment in VSCode that enables full debugging of the code? Any help here would be greatly appreciated.

Thanks.

  • Mike

Seems there’s a service module that’s launching code in another thread. But I’m not even sure my version of the code is what’s running actually. (I edited one file in he syncthing core to make a syntax error, and launching still worked, and the code is running.) Is it possible it’s running some other code version? perhaps downloaded from github directly?

Anyway, I need a little help to figure out how to set this up before I can even think about contributing…

FYI I’ve been programming for a long time, originally with languages like C, C++, VisualBasic (don’t judge) and most recently python. This is my first experience with Go.

Haven’t checked: Afaik we always run a monitor process “wrapping the main one”.

No idea about vscode and what’s happening - I only ever used delve standalone on the command line when debugging stuff (and very rarely).

Thanks for the reply.

not sure what the issue was but it’s working now. I’m able to set breakpoints and step through the go code in vscode and also debug the javascript in the chrome browser.

A lot of the code is confusing to me still. There’s a lot to it, and I expect it will take a while to figure out how it all works.

1 Like

Nice. I’ve been using VSCode for a long time but still haven’t gotten around to trying the debugger/breakpoints.

Are you looking for/at something specific? Figuring out how it all works sounds very daunting :slight_smile:

Well I was looking for an excuse to learn Go and interested in the project since it’s very useful to me personally and also useful at work.

So I thought I would try to get it compiling and see if I could setup a debug environment if I were gonna be able to contribute at some point.

Then I started looking at the existing “issues” and picked a simple one… and found yeah the code is complex and even simple issues aren’t so simple. Haha. Maybe that’s why some of them have been sitting for a while.

Anyway it’s all part of the learning process. Im well versed in git and revision control in general but have mostly been a single developer working on my own projects and not contributing to someone else’s project.

A lot to learn about a lot of things here.

4 Likes