Giter Site home page Giter Site logo

Discussion about formatting about delve HOT 7 CLOSED

go-delve avatar go-delve commented on August 22, 2024
Discussion about formatting

from delve.

Comments (7)

derekparker avatar derekparker commented on August 22, 2024
  1. Support both a human readable format and a separate machine readable output format (for IDE integration).

What did you have in mind for a machine readable output?

  1. Standardize when the type name is shown in the human readable format. My first thought is to never show it when using the print command and add a ptype command to print the type of a variable on demand.

Yeah, I definitely agree with this. I think this also extends into any nonessential information we display about variables, i.e. displaying len and cap for slices is most likely unnecessary. Maybe we have a command to display extended information about a variable, including type and any other metadata associated with it.

  1. Support slice syntax for printing arrays. print x prints the first 64 elements, print x[0] prints the first element, print x[10:12] prints elements 10 to 12 etc.

Absolutely.

  1. Support pretty-printing for structs. This could be switched off and on.

Good idea, maybe a flag for the print command, or a runtime configuration to enable pretty printing? I'm definitely open to suggestions.

from delve.

epipho avatar epipho commented on August 22, 2024

What did you have in mind for a machine readable output?

Not sure, maybe json? Something standard so people can focus on integration rather than on how to parse the output.

Good idea, maybe a flag for the print command, or a runtime configuration to enable pretty printing? > I'm definitely open to suggestions.

I like GDB's combo of runtime config + startup script to set the defaults. Opens a lot of doors for customizing other output such as switching to machine readable output, chaning the default number of elements etc.

from delve.

derekparker avatar derekparker commented on August 22, 2024

Not sure, maybe json? Something standard so people can focus on integration rather than on how to parse the output.

JSON sounds fine to me.

I like GDB's combo of runtime config + startup script to set the defaults. Opens a lot of doors for customizing other output such as switching to machine readable output, chaning the default number of elements etc.

Currently, there's no real way to configure Delve. I'd definitely like to talk through adding configuration to Delve. A startup script, or some sort of config file in the users home dir paired with maybe a command to set / list runtime variables.

from delve.

pnasrat avatar pnasrat commented on August 22, 2024

+1 on JSON, it's pretty clear - definitely being able to log/redirect output to a file also (cf set logging file ) and enable/disable pagination for human interaction and scripted modes.

from delve.

pnasrat avatar pnasrat commented on August 22, 2024

I also wonder if being able to output runtime/debug and pprof style info directly in delve would be useful. At least a quick hook to dump expvar into json may be worth it even if not the heap/gc/profile hooks.

from delve.

dlsniper avatar dlsniper commented on August 22, 2024

May I suggest https://github.com/kr/pretty as a possible solution for pretty printing structs / maps.

As a small example:

package main

import "github.com/kr/pretty"

func main() {
    type (
        miniStr struct {
            mini string
        }

        str struct {
            payload  string
            payload2 miniStr
        }
    )

    a := map[string]map[string]str{
        "a": map[string]str{
            "b": str{
                payload: "c",
                payload2: miniStr{
                    mini:  "d",
                    mini2: "e",
                },
            },
        },
        "a2": map[string]str{
            "b2": str{
                payload: "c2",
                payload2: miniStr{
                    mini:  "d2",
                    mini2: "e2",
                },
            },
        },
    }

    pretty.Printf("%# v\n", a)
}
map[a:map[b:{payload:c payload2:{mini:d mini2:e}}] a2:map[b2:{payload:c2 payload2:{mini:d2 mini2:e2}}]]

map[string]map[string]main.str{
    "a": {
        "b": {
            payload:  "c",
            payload2: main.miniStr{mini:"d", mini2:"e"},
        },
    },
    "a2": {
        "b2": {
            payload:  "c2",
            payload2: main.miniStr{mini:"d2", mini2:"e2"},
        },
    },
}

from delve.

derekparker avatar derekparker commented on August 22, 2024

Moving discussion related issues to mailing list. Please see (https://groups.google.com/forum/#!forum/delve-dev) for further discussion.

from delve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.