go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.89k stars 2.14k forks source link

Why map not shown in struct? #610

Closed kolkov closed 7 years ago

kolkov commented 8 years ago

Content of svPtr.nameMap not shown in debugger variables...

package main

import (
    "fmt"
)

type (
    structInfo struct {
        nameMap   map[string]*fieldInfo // mapping from struct field names to field infos
        pkNames   []string              // struct field names representing PKs
    }

    structValue struct {
        *structInfo
        tableName string        // the db table name for the struct
    }

    fieldInfo struct {
        name   string // field name
        dbName string // db column name
    }
)

func main(){
    fi1Ptr := &fieldInfo{
        dbName: "dbName1",
        name: "name1",
    }
    fmt.Printf("%+v\n", fi1Ptr)

    fi2Ptr := &fieldInfo{
        dbName: "dbName2",
        name: "name2",
    }
    fmt.Printf("%+v\n", fi2Ptr)

    mapFi := map[string]*fieldInfo{
        "fieldInfo1": fi1Ptr,
        "fieldInfo2": fi2Ptr,
    }
    fmt.Printf("%+v\n", mapFi)

    mapNames := []string{"one", "two"}

    siPtr := &structInfo{
        nameMap: mapFi,
        pkNames: mapNames,
    }

    svPtr :=&structValue{
        structInfo: siPtr,
        tableName: "tableName",
    }
    fmt.Printf("%+v\n", svPtr)
    fmt.Printf("%+v\n", svPtr.nameMap)
}
C:/Go\bin\go.exe build -o C:\Users\Andy\AppData\Local\Temp\Unnamedgo -gcflags "-N -l" tests/nameMap(DELVE)
API server listening at: 127.0.0.1:7109
&{name:name1 dbName:dbName1}
&{name:name2 dbName:dbName2}
map[fieldInfo1:0xc042040400 fieldInfo2:0xc042040480]
&{structInfo:0xc0420404e0 tableName:tableName}
map[fieldInfo1:0xc042040400 fieldInfo2:0xc042040480]

image

https://github.com/go-ozzo/ozzo-dbx/blob/master/struct.go

aarzilli commented 8 years ago

You just reached the maximum recursion depth, with the command line version of delve you would be able to do: print svPtr.nameMap to see the value of svPtr.nameMap, I don't know how to do it inside IntelliJ.

cc @dlsniper

dlsniper commented 8 years ago

I think we need to do a better job at detecting the struct type and render it. @aarzilli I'd suggest keeping this open for now in case we want to contribute back to delve a way to just list the map and values w/o the internal structure (in order to simplify the clients).

@kolkov please open an issue in the plugin repo linked to this. Thank you.

aarzilli commented 7 years ago

Closing, client problem.