我的 Go 编程需要这个答案。答案与 Tobias 提供的答案略有不同(也许我有一个更新版本的调试器)。

以下是如何更改在调试器中可以看到的字符串长度:

  1. 设置你的 go 程序进行调试(为 vs 代码安装 go 扩展)

  2. 在您的工作区中,将有一个 .vscode 目录。其中有一个名为launch.json 的文件。如果一个不存在,那么当您即将启动调试器时,您可以创建一个。

  3. 编辑 launch.json 文件。它将有一个简单的 JSON conf。扩展该 JSON,使其看起来像这样(我将最大长度扩展到 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

        }

    }

    ]

}