dongshang4984 2019-08-08 14:22
浏览 294
已采纳

运行Golang调试器时,VSCode调试不会在VARIABLES区域中显示映射值

Let's say this map is s.S.Data, it shows that the length of the map is 2, but just displays nothing. When I add expression s.S in WATCH area, it displays correctly. screenshot

there is the sample:

package main

import (
    "fmt"
)

type Some struct {
    ID   int
    Data map[string]string
    S    *Some
}

func Print(s Some) {
    var t Some
    t = s // Breakpoint
    fmt.Println(t)
    if t.S != nil {
        fmt.Println(t.S)
    }
}

func main() {
    s := Some{
        ID: 2333,
        Data: map[string]string{
            "1": "A",
            "2": "B",
        },
    }
    ss := Some{
        ID: 7777,
        S:  &s,
    }
    Print(ss)
    fmt.Println("Hello, playground")
}

Is there any way to make it display correctly in VARIABLES area?

  • 写回答

1条回答 默认 最新

  • drkwpgrdb092239314 2019-08-09 04:14
    关注

    tl;dr: set go.delveConfig.dlvLoadConfig.maxVariableRecurse other than 1.

    More detail:

    Open preferences and type delve and then press Edit in settings.json.

    (note: if you choose User tab it will be applied to all VSCode projects, otherwise it will only be applied to this project.)

    enter image description here

    After that settings.json will be opened with empty JSON object. Write down go.d and then there should be autocompletion for go.delveConfig popping up.enter image description here

    By pressing enter, you'll get a boilerplate setting for delve, which is a GoLang debugger used by VSCode. Edit the value of "maxVariableRecurse" key other than 1 and then you will be able to see the deeper variables.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化
  • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数