3

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

You'll notice that this setting as a signficant performance impact. When you set this to 3 the debugger will run your process much slower.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.