Code Monkey home page Code Monkey logo

Comments (1)

Russtopia avatar Russtopia commented on May 18, 2024

My apologies for not updating this more promptly. I came up with a sufficient solution many months ago, which I neglected to submit here until now.

Rather than some complex addition to the go-callvis codebase, it ultimately seemed best to just use a post-processing script to achieve this, since it is not really the responsibility of go-callvis to name nodes in the graph, but the dot tool beneath, which is language-agnostic.

My solution was to place a formatted comment tag above a goroutine, naming it as desired, eg:

func doShellMode(...) {
        ...
        // #gv:s/label=\"doShellMode\$1\"/label=\"shellRemoteToStdin\"/
        shellRemoteToStdin := func() {
            ...
            ...
        }
        go shellRemoteToStdin()
}

The #gv introduces a sed expression used by the following script, called from a vis build rule in my Makefiles, to patch the .gv files output by graphvis to use the desired name for the node.

fixup-gv.sh

#!/bin/bash

inFile="${1/.go/}"
visFile="${inFile}-vis.gv"

grep -o "#gv:.*" "$inFile.go" | cut -f2 -d: | \
while read -r expr; do sed -i ${expr} "${visFile}"; done

I typically create a 'vis' Makefile target which invokes fixup-gv.sh to generate the graphics for all files in the project.

Example: https://gogs.blitter.com/RLabs/hkexsh/wiki

It might be nice to include the above 'fixup-gv.sh' script as a helper within this project, or as part of an FAQ on how to name goroutines in the go-callvis output. Other than that, it shouldn't be worth effort within the golang codebase of this project.

from go-callvis.

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.