Code Monkey home page Code Monkey logo

Comments (15)

hediet avatar hediet commented on April 28, 2024 1

Can you try out to visualize this expression:

""{\"kind\":{\"graph\":true},\"nodes\":[{\"id\":\"1\"},{\"id\":\"2\"}],\"edges\":[{\"from\":\"1\",\"to\":\"2\"}]}""

If that does not work, can you enter the same expression in VS Codes watch window and post a screenshot of the result here?

from vscode-debug-visualizer.

birdie7761 avatar birdie7761 commented on April 28, 2024 1
package main

import (
	"encoding/json"
	"fmt"
	"math/rand"
	"strconv"
	"time"
)

type Graph struct {
	Kind  map[string]bool `json:"kind"`
	Nodes []NodeGraphData `json:"nodes"`
	Edges []EdgeGraphData `json:"edges"`
}

type NodeGraphData struct {
	ID    string `json:"id"`
	Label string `json:"label,omitempty"`
	Color string `json:"color,omitempty"`
	Shape string `json:"shape,omitempty"`
}

type EdgeGraphData struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Label  string `json:"label,omitempty"`
	ID     string `json:"id"`
	Color  string `json:"color,omitempty"`
	Dashes bool   `json:"dashes,omitempty"`
}

func NewGraph() *Graph {
	return &Graph{
		Kind:  map[string]bool{"graph": true},
		Nodes: []NodeGraphData{},
		Edges: []EdgeGraphData{},
	}
}

func (this *Graph) toString() string {
	rs, _ := json.Marshal(this)
	return string(rs)
}

func main() {
	rand.Seed(time.Now().UnixNano())
	graph := NewGraph()
	for i := 2; i < 100; i++ {
		id := strconv.Itoa(i)
		graph.Nodes = append(graph.Nodes, NodeGraphData{
			ID:    id,
			Label: id,
		})
		targetId := rand.Intn(i) + 1
		graph.Edges = append(graph.Edges, EdgeGraphData{
			From: id,
			To:   strconv.Itoa(targetId),
		})
		s := graph.toString()
		fmt.Printf("%s", s)
	}
}

from vscode-debug-visualizer.

hantmac avatar hantmac commented on April 28, 2024

Can you try out to visualize this expression:

""{\"kind\":{\"graph\":true},\"nodes\":[{\"id\":\"1\"},{\"id\":\"2\"}],\"edges\":[{\"from\":\"1\",\"to\":\"2\"}]}""

If that does not work, can you enter the same expression in VS Codes watch window and post a screenshot of the result here?

  1. Does not work
  2. After entering the same expression in VS Codes watch window the screenshot is:
    image

from vscode-debug-visualizer.

hediet avatar hediet commented on April 28, 2024

You need to start a debug session by debugging a golang program!
This extension requires the debugger to evaluate expressions.
I'm working on improving the error messages.

from vscode-debug-visualizer.

birdie7761 avatar birdie7761 commented on April 28, 2024

image

from vscode-debug-visualizer.

hediet avatar hediet commented on April 28, 2024

@birdie7762 thanks for the screenshot ;) You can make it dynamic by calling a method that returns such a string.

from vscode-debug-visualizer.

hediet avatar hediet commented on April 28, 2024

@birdie7761 Would you mind porting this demo to golang and creating a PR? That would be awesome! :)

from vscode-debug-visualizer.

birdie7761 avatar birdie7761 commented on April 28, 2024

image

from vscode-debug-visualizer.

birdie7761 avatar birdie7761 commented on April 28, 2024

{"kind":{"graph":true},"nodes":[{"id":"2","label":"2"}],"edges":[{"from":"2","to":"2","id":""}]}

from vscode-debug-visualizer.

hediet avatar hediet commented on April 28, 2024

@birdie7761 thanks a lot :) If you want to be listed as contributer to this project in github, you can fork this repository and open a pull request with your file in the demo folder! (otherwise I can simply commit it by myself)

from vscode-debug-visualizer.

hantmac avatar hantmac commented on April 28, 2024

That's Great!

from vscode-debug-visualizer.

birdie7761 avatar birdie7761 commented on April 28, 2024

@birdie7761 thanks a lot :) If you want to be listed as contributer to this project in github, you can fork this repository and open a pull request with your file in the demo folder! (otherwise I can simply commit it by myself)

@hediet My English is very poor. I'm using a translator, so I haven't had a text reply to you before. PR I've created.(#37)
The golang serialized output of json cannot be displayed correctly.
The error information is as follows:

Error: Could not parse "{"kind":{"graph":true},"nodes":[{"id":"2","label":"2"}],"edges":...+32 more" as JSON. Unexpected token k in JSON at position 3

from vscode-debug-visualizer.

hediet avatar hediet commented on April 28, 2024

My English is very poor. I'm using a translator, so I haven't had a text reply to you before.

No problem ;)

PR I've created.(#37)

Thank you!

Sorry, I didn't look at your screenshot properly. Thanks for providing it!
Looks like it choked on ... + 32 more. It's interesting that the Debug Console does not has this ... + 32 more. I guess the debug adapter adds this text when the string gets too long.

Which debug adapter do you use?

from vscode-debug-visualizer.

birdie7761 avatar birdie7761 commented on April 28, 2024

The debug used is delve

Delve's maxStringLen default is small and needs to be adjusted for the maxStringLen default of the delve. See in detail (microsoft/vscode-go#868).
Add the following configuration to launch.json

"dlvLoadConfig": {
                "followPointers": true,
                "maxVariableRecurse": 1,
                "maxStringLen": 500,
                "maxArrayValues": 64,
                "maxStructFields": -1
            }

Adjustments can already be shown.
image

from vscode-debug-visualizer.

hediet avatar hediet commented on April 28, 2024

Closing this as I've verified that the golang demo works.

from vscode-debug-visualizer.

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.