Using an IDE is recommended as it makes it a lot easier to work with the TiDB code, for example to see the fields of a struct. However it is not required to use a specific IDE or editor. You can use the IDE or editor of your choice.
GoLand
You can use GoLand to easily run or debug TiDB in many situations.
Prerequisites
go: TiDB is a Go project. Therefore, you need a working Go environment to build it. See the previous Install Golang section to prepare the environment.
Follow the instructions and open the TiDB source code in GoLand.
Open TiDB source code in GoLand
Populate run configurations
Under the root directory of the TiDB source code, execute the following commands to add config files:
Now, confirm there are three config files:
Run or debug
Now you can see the run/debug configs right upper the window.
Run Configs
The first config is unistore 4000, which enables you to run/debug TiDB independently without TiKV, PD, and TiFlash.
unistore config
unistore output
The second config is playground attach 4001, which enables you to run/debug TiDB by attaching to an existing cluster; for example, a cluster deployed with tiup playground.
After the server process starts, you can connect to the origin TiDB by port 4000, or connect to your TiDB by port 4001 at the same time.
playground attach config
playground attach debug
The third config is unit test, which enables you to run/debug unit tests. You may modify the Directory and Pattern to run other tests.
unit test config
unit test output
If you encounter any problems during your journey, do not hesitate to reach out on the TiDB Internals forum.
Visual Studio Code
VS Code is a generic IDE that has good extensions for working with Go and TiDB.
VS Code with TiDE
Prerequisites
go: TiDB is a Go project thus its building requires a working go environment. See the previous Install Golang section to prepare the environment.