I have been having trouble seeing the entire value of variables while debugging in Go. When I click on a rather long value, it shows me ... +# more. But I can't find a way to see the rest of that value. Even in watch mode it does the same thing, even when I click copy value it copies the ...+# more. Here is an example below. Anyone know how to see the rest of the +114 more?
"Some really really long string..+114 more"
When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.
Start debugging. Execution pauses at the breakpoint. Select the variable a in the code. Select Debug > QuickWatch, press Shift+F9, or right-click and select QuickWatch.
You can configure delve in the vscode settings.json.
There is a parameter called "maxStringLen" you can set it to a higher value. I do not recommend setting the values to high. The debugger can get very slow if you set the maxStringLen, maxArrayValues, etc. to high. So if you play arround with these delve settings and your debugger gets slow, better chose lower values again.
Here is an example showing maxStringLen and some other possible values:
"go.delveConfig": {
"useApiV1": false,
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 3,
"maxStringLen": 400,
"maxArrayValues": 400,
"maxStructFields": -1
}
}
I needed this answer for my go programming. The answer is a little different than the one provided by Tobias (perhaps I have a newer version of the debugger).
Here's how to change the length of the strings you can see in the debugger:
Set up your go program for debugging (install the go extension for vs code)
In your workspace, there will be a .vscode directory. In there is a file called launch.json. If one does not exist, then when you are about to launch the debugger, you can create one.
Edit the launch.json file. It will have a simple JSON conf in it. Extend that JSON so that it looks like this (I extended the maximum length to 400):
{
// 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": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"apiVersion": 2,
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 400,
"maxArrayValues": 64,
"maxStructFields": -1
}
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With