Visualize call graph of a Go program using Graphviz

gopher

go-callvis

Github release Build status Slack channel

go-callvis is a development tool to help visualize call graph of a Go program using interactive view.


Introduction

The purpose of this tool is to provide developers with a visual overview of a Go program using data from call graph and its relations with packages and types. This is especially useful in larger projects where the complexity of the code much higher or when you are just simply trying to understand code of somebody else.

Features

  • 🆕 support for Go modules! 💥
  • focus specific package in the program
  • click on package to quickly switch the focus using interactive viewer
  • group functions by package and/or methods by type
  • filter packages to specific import path prefixes
  • ignore funcs from standard library
  • omit various types of function calls

Output preview

main

Check out the source code for the above image.

How it works

It runs pointer analysis to construct the call graph of the program and uses the data to generate output in dot format, which can be rendered with Graphviz tools.

Reference guide

Here you can find descriptions for various types of output.

Packages / Types

Represents Style
focused blue color
stdlib green color
other yellow color

Functions / Methods

Represents Style
exported bold border
unexported normal border
anonymous dotted border

Calls

Represents Style
internal black color
external brown color
static solid line
dynamic dashed line
regular simple arrow
concurrent arrow with circle
deferred arrow with diamond

Quick start

Requirements

  • Go 1.13+
  • Graphviz (optional, required only with -graphviz flag)

Installation

go get -u github.com/ofabry/go-callvis
# or
git clone https://github.com/ofabry/go-callvis.git
cd go-callvis && make install

Usage

Interactive viewer

To use the interactive view provided by a web server that serves SVG images of focused packages, you can simply run:

go-callvis <target package>

HTTP server is listening on http://localhost:7878/ by default, use option -http="ADDR:PORT" to change HTTP server address.

Render static output

To generate a single output file use option -file=<file path> to choose output file destination.

The output format defaults to svg, use option -format=<svg|png|jpg|...> to pick a different output format.

Options

Usage of go-callvis:
  -debug
    	Enable verbose log.
  -file string
    	output filename - omit to use server mode
  -cacheDir string
    	Enable caching to avoid unnecessary re-rendering.
  -focus string
    	Focus specific package using name or import path. (default "main")
  -format string
    	output file format [svg | png | jpg | ...] (default "svg")
  -graphviz
    	Use Graphviz's dot program to render images.
  -group string
    	Grouping functions by packages and/or types [pkg, type] (separated by comma) (default "pkg")
  -http string
    	HTTP service address. (default ":7878")
  -ignore string
    	Ignore package paths containing given prefixes (separated by comma)
  -include string
    	Include package paths with given prefixes (separated by comma)
  -limit string
    	Limit package paths to given prefixes (separated by comma)
  -minlen uint
    	Minimum edge length (for wider output). (default 2)
  -nodesep float
    	Minimum space between two adjacent nodes in the same rank (for taller output). (default 0.35)
  -nointer
    	Omit calls to unexported functions.
  -nostd
    	Omit calls to/from packages in standard library.
  -skipbrowser
    	Skip opening browser.
  -tags build tags
    	a list of build tags to consider satisfied during the build. For more information about build tags, see the description of build constraints in the documentation for the go/build package
  -tests
    	Include test code.
  -version
    	Show version and exit.

Run go-callvis -h to list all supported options.

Examples

Here is an example for the project syncthing.

syncthing example

Check out more examples and used command options.

Community

Join #go-callvis channel at gophers.slack.com. (not a member yet? get invitation)

How to help

Did you find any bugs or have some suggestions?

  • Feel free to open new issue or start discussion in the slack channel.

Do you want to contribute to the project?

  • Fork the repository and open a pull request. Here you can find TODO features.

Roadmap

The interactive tool described below has been published as a separate project called goexplorer!

Ideal goal of this project is to make web app that would locally store the call graph data and then provide quick access of the call graphs for any package of your dependency tree. At first it would show an interactive map of overall dependencies between packages and then by selecting particular package it would show the call graph and provide various options to alter the output dynamically.

Comments
  • [Question] can't generate the call graph for hashicorp/raft

    [Question] can't generate the call graph for hashicorp/raft

    I use the below command"

    go-callvis -focus github.com/hashicorp/raft github.com/hashicorp/raft -limit github.com/hashicorp/raft -nostd
    

    but there are many errors:

    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:58:15: undeclared name: crand
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:59:9: undeclared name: fmt
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:62:9: undeclared name: fmt
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:129:9: undeclared name: fmt
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:132:9: invalid operation: buf (variable of type *invalid type) has no field or method Bytes
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:140:9: undeclared name: fmt
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:154:7: undeclared name: bytes
    /Users/yuepan/go/src/github.com/hashicorp/raft/util.go:162:9: undeclared name: bytes
    cannot find package "-limit" in any of:
    	/usr/local/Cellar/go/1.7.4/libexec/src/-limit (from $GOROOT)
    	/Users/yuepan/go/src/-limit (from $GOPATH)
    cannot find package "-nostd" in any of:
    

    Maybe I have made a mistake to use it.

    My question is how to use it for github.com/hashicorp/raft github.com/hashicorp/raft

  • Internal panic in pointer analysis

    Internal panic in pointer analysis

    go-callvis crashed when I try to make call graph of project "lnd":
    Here is the log:

    jason@lenovo:~/go/src/github.com/TrueFurby/go-callvis$ go-callvis -nostd -group pkg -limit github.com/lightningnetwork  github.com/lightningnetwork/lnd | dot -Tpng -o output.png
    Internal panic in pointer analysis:
    goroutine 1 [running]:
    runtime/debug.Stack(0x24, 0x0, 0x0)
    	/usr/local/go/src/runtime/debug/stack.go:24 +0xa7
    runtime/debug.PrintStack()
    	/usr/local/go/src/runtime/debug/stack.go:16 +0x22
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.Analyze.func1(0xc420119a00)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/analysis.go:227 +0x124
    panic(0x6ad6a0, 0xc452e5e060)
    	/usr/local/go/src/runtime/panic.go:491 +0x283
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.(*analysis).taggedValue(0xc448689340, 0xc4000365ac, 0x1, 0x64, 0xc425d18700)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/gen.go:272 +0x145
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.(*untagConstraint).solve(0xc4495cc420, 0xc448689340, 0xc481759740)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/solve.go:295 +0xd5
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.(*analysis).solveConstraints(0xc448689340, 0xc4483e6ab0, 0xc481759740)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/solve.go:165 +0x99
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.(*analysis).solve(0xc448689340)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/solve.go:59 +0x2e4
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.Analyze(0xc42c506a50, 0x0, 0x894460, 0xc452e5e0c0)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/analysis.go:331 +0x6b1
    main.run(0x8b2f80, 0x71af6a, 0x4, 0xc420119ea8, 0xc4200de120, 0x1, 0x1, 0x8d1b98, 0x0, 0x0, ...)
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/main.go:159 +0x7ba
    main.main()
    	/home/jason/go/src/github.com/TrueFurby/go-callvis/main.go:77 +0x7ee
    go-callvis: internal error in pointer analysis: not a tagged object: n222636 (please report this bug)
    
    
  • Visualize call graph of Go libs

    Visualize call graph of Go libs

    Can go-callvis be used to visualize call graph for Go libs? I got go-callvis: no main packages by doing so, and no output generated.

    Here are details:

    gpkg=github.com/andrew-d/goscrape
    
    $ go-callvis -limit $gpkg -focus $gpkg $gpkg | dot -Tpng -o /tmp/out.png
    go-callvis: no main packages
    
    $ ls /tmp/out.png
    ls: cannot access '/tmp/out.png': No such file or directory
    
    
  • Large project

    Large project

    I have a large project (mainly a lot of generated codes) and facing this error: dot: graph is too large for cairo-renderer bitmaps. Scaling by 0.235786 to fit it is useless for that main package, can this render large image without scaling it?

    ps: tried with svg but dot failed.

  • Add options -format,-file for PNG/SVG file output

    Add options -format,-file for PNG/SVG file output

    Addition of -output, -svg, -png options to run go-callvis in a non-server mode to just output image files. Useful for scripting eg., makefile targets to generate graphvis for modules non-interactively.

  • go-callvis for quorum packages

    go-callvis for quorum packages

    git clone https://github.com/jpmorganchase/quorum.git Iam trying this command go-callvis -focus upgrade -group pkg,type -limit github.com/jpmorganchase/quorum github.com/jpmorganchase/quorum

    output- go-callvis: cannot find package "upgrade" in any of: /usr/local/go/src/upgrade (from $GOROOT) /home/ubuntu/go/src/upgrade (from $GOPATH)

  • mac 10.3 make failed

    mac 10.3 make failed

    cd github.com/TrueFurby/go-callvis/ && make

    go get github.com/golang/dep/cmd/dep dep ensure -update make: dep: No such file or directory make: *** [dep] Error 1

  • Generate call graph for packages that depends on Go 1.16

    Generate call graph for packages that depends on Go 1.16

    Hi,

    • My Go is go-1.15, and
    • I downloaded github.com/xo/xo which needs Go 1.16 to compile and
    • I want to use go-callvis to generate call graph for it, but

    This is what I got:

    $ go-callvis -ignore embed,io/fs .
    templates/templates.go:6:2: cannot find package "embed" in any of:
            /usr/lib/go-1.15/src/embed (from $GOROOT)
            /path/to/Go/src/embed (from $GOPATH)
    templates/templates.go:8:2: cannot find package "io/fs" in any of:
            /usr/lib/go-1.15/src/io/fs (from $GOROOT)
            /path/to/Go/src/io/fs (from $GOPATH)
    /path/to/Go/src/github.com/xo/xo/templates/templates.go:6:2: could not import embed (invalid package name: "")
    /path/to/Go/src/github.com/xo/xo/templates/templates.go:8:2: could not import io/fs (invalid package name: "")
    /path/to/Go/src/github.com/xo/xo/cmd/cmd.go:231:53: DirFS not declared by package os
    . . .
    

    I've already use -ignore embed,io/fs to tell go-callvis to ignore embed,io/fs, but why it is still trying to work on it?

    Internally, how does thing work? E.g, if I got one go-callvis compiled with go-1.16, would it understand packages that depends on Go 1.16, while my go is still 1.15?

    thanks

  • Panic on callEdge dynamic function call

    Panic on callEdge dynamic function call

    Internal panic in pointer analysis:
    goroutine 1 [running]:
    runtime/debug.Stack(0x24, 0x0, 0x0)
    	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/debug/stack.go:24 +0xa7
    runtime/debug.PrintStack()
    	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/debug/stack.go:16 +0x22
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.Analyze.func1(0xc44341fa00)
    	/Users/*********/code/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/analysis.go:227 +0x124
    panic(0x12aa0a0, 0xc44db24cc0)
    	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/panic.go:491 +0x283
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.(*analysis).callEdge(0xc4296461c0, 0xc4258ad080, 0xc43bc346c0, 0x13eef)
    	/Users/*********/code/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/analysis.go:368 +0x937
    github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer.Analyze(0xc43386d720, 0x0, 0x1490440, 0xc44db24e40)
    	/Users/*********/code/src/github.com/TrueFurby/go-callvis/vendor/golang.org/x/tools/go/pointer/analysis.go:354 +0x8b8
    main.run(0x14ae8e0, 0x1316ee6, 0x4, 0xc44341fea8, 0x14cd4e8, 0x0, 0x0, 0x14cd4e8, 0x0, 0x0, ...)
    	/Users/*********/code/src/github.com/TrueFurby/go-callvis/main.go:159 +0x7ba
    main.main()
    	/Users/*********/code/src/github.com/TrueFurby/go-callvis/main.go:77 +0x7ee
    go-callvis: internal error in pointer analysis: callEdge dynamic function call -> n81647: not a function object (please report this bug)
    
  • Startup problems?

    Startup problems?

    Hello -- looks like a great tool. However, after following your install procedure, when I run go-callvis using your example I get this: go-callvis -focus upgrade -limit github.com/syncthing/syncthing github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing_focus.png /opt/Projects/Golang/src/github.com/syncthing/syncthing/cmd/syncthing/gui_statics.go:37:13: Assets not declared by package auto /opt/Projects/Golang/src/github.com/syncthing/syncthing/cmd/syncthing/gui_statics.go:44:20: Assets not declared by package auto /opt/Projects/Golang/src/github.com/syncthing/syncthing/cmd/syncthing/gui_statics.go:44:20: cannot range over auto.Assets() (invalid operand) go-callvis: couldn't load packages due to errors: github.com/syncthing/syncthing/cmd/syncthing

    Am I doing something wrong?

  • Generate call and report error

    Generate call and report error

    Unable to generate call graph

    $ go-callvis main.go 
    panic: in crypto/sha256.Sum224: cannot convert slice t0[:] ([]byte) to *[28]byte
    
    goroutine 3336 [running]:
    golang.org/x/tools/go/ssa.emitConv(0xc014ef7900, {0xb8b0d8, 0xc020b80600}, {0xb86bb8?, 0xc00b8da4c0})
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/emit.go:242 +0x7c7
    golang.org/x/tools/go/ssa.(*builder).expr0(0xa2b440?, 0xc014ef7900, {0xb87ad8?, 0xc00b66af00}, {0x7, {0xb86bb8, 0xc00b8da4c0}, {0x0, 0x0}})
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:573 +0x925
    golang.org/x/tools/go/ssa.(*builder).expr(0xc0204dd6b8?, 0xc014ef7900, {0xb87ad8?, 0xc00b66af00?})
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:530 +0x19f
    golang.org/x/tools/go/ssa.(*builder).assign(0xc014ef7900?, 0xc014ef7900?, {0xb88dc0?, 0xc0204fab70}, {0xb87ad8?, 0xc00b66af00?}, 0x0?, 0xc019a995d0)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:502 +0x3db
    golang.org/x/tools/go/ssa.(*builder).assignStmt(0xa0cb40?, 0xc014ef7900, {0xc00b66e500, 0x1, 0x2?}, {0xc00b66e520, 0x1, 0xc0204f54c0?}, 0x1)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:1050 +0x25d
    golang.org/x/tools/go/ssa.(*builder).stmt(0x0?, 0xc014ef7900, {0xb87958?, 0xc00b66af40?})
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2009 +0x1094
    golang.org/x/tools/go/ssa.(*builder).stmtList(0x0?, 0x7f7ac78fc828?, {0xc00b656780?, 0x7, 0x20?})
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:790 +0x67
    golang.org/x/tools/go/ssa.(*builder).stmt(0xc014ef7900?, 0xc014ef7900, {0xb87a78?, 0xc00b66c7e0?})
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2105 +0x1331
    golang.org/x/tools/go/ssa.(*builder).buildFunction(0xa2b740?, 0xc014ef7900)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2198 +0x465
    golang.org/x/tools/go/ssa.(*builder).buildFuncDecl(0xa2b740?, 0xc019efae40, 0xc00b66c810)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2228 +0x154
    golang.org/x/tools/go/ssa.(*Package).build(0xc019efae40)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2344 +0xd05
    sync.(*Once).doSlow(0xc0066760b0?, 0xc006447638?)
            /opt/golang/default/src/sync/once.go:68 +0xc2
    sync.(*Once).Do(...)
            /opt/golang/default/src/sync/once.go:59
    golang.org/x/tools/go/ssa.(*Package).Build(...)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2263
    golang.org/x/tools/go/ssa.(*Program).Build.func1(0x0?)
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2247 +0x4c
    created by golang.org/x/tools/go/ssa.(*Program).Build
            /home/chenchong/.local/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2246 +0x19c
    
    

    My golang version

    $ go version
    go version go1.18 linux/amd64
    

    My project go Mod information

    module XXX
    
    go 1.16
    
    require (
    	...
    )
    
  • docs: use 'go install' instead of 'go get'

    docs: use 'go install' instead of 'go get'

    As of Go 1.17, 'go get' is deprecated, and as of 1.18 'go get' will no longer build packages. 'go install' should be used instead, see https://go.dev/doc/go-get-install-deprecation

    Signed-off-by: mikaello [email protected]

  • panic: interface conversion: types.Type is nil, not *types.Signature

    panic: interface conversion: types.Type is nil, not *types.Signature

    Version: v0.61 (current latest)

    I get the following panic while analyzing a private piece of code:

    myproject> go-callvis .
    panic: interface conversion: types.Type is nil, not *types.Signature
    
    goroutine 4220 [running]:
    golang.org/x/tools/go/ssa.(*builder).expr0(0x1577a40?, 0xc0223843c0, {0x16e2988?, 0xc015f79c80}, {0x0, {0x0, 0x0}, {0x0, 0x0}})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:679 +0x1ba8
    golang.org/x/tools/go/ssa.(*builder).expr(0x1576a80?, 0xc0223843c0, {0x16e2988?, 0xc015f79c80?})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:530 +0x19f
    golang.org/x/tools/go/ssa.(*builder).expr0(0x1577a40?, 0xc0223843c0, {0x16e2c28?, 0xc008cd27c8}, {0x2, {0x16e1760, 0xc0032052c0}, {0x0, 0x0}})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:697 +0x14dd
    golang.org/x/tools/go/ssa.(*builder).expr(0x1576a80?, 0xc0223843c0, {0x16e2c28?, 0xc008cd27c8?})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:530 +0x19f
    golang.org/x/tools/go/ssa.(*builder).setCallFunc(0x80?, 0xc0223843c0?, 0xc003204200?, 0xc0248b92c0)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:881 +0x30c
    golang.org/x/tools/go/ssa.(*builder).setCall(0x1577a40?, 0xc0223843c0, 0xc003204200, 0xc0248b92c0)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:962 +0x31
    golang.org/x/tools/go/ssa.(*builder).expr0(0x1577a40?, 0xc0223843c0, {0x16e2688?, 0xc003204200}, {0x7, {0x16e1788, 0xc00d62a090}, {0x0, 0x0}})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:596 +0x1e9e
    golang.org/x/tools/go/ssa.(*builder).expr(0xc0223843c0?, 0xc0223843c0, {0x16e2688?, 0xc003204200?})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:530 +0x19f
    golang.org/x/tools/go/ssa.(*builder).stmt(0x0?, 0xc0223843c0, {0x16e2bc8?, 0xc015f79da0?})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2048 +0x2232
    golang.org/x/tools/go/ssa.(*builder).stmtList(0x2030092?, 0x22970f34050?, {0xc0032040c0?, 0x4, 0x20?})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:790 +0x67
    golang.org/x/tools/go/ssa.(*builder).stmt(0xc0223843c0?, 0xc0223843c0, {0x16e2628?, 0xc00c700b10?})
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2105 +0x18bd
    golang.org/x/tools/go/ssa.(*builder).buildFunction(0x1577d40?, 0xc0223843c0)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2198 +0x47a
    golang.org/x/tools/go/ssa.(*builder).buildFuncDecl(0x1576d20?, 0xc022302540, 0xc00c700b40)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2228 +0x154
    golang.org/x/tools/go/ssa.(*Package).build(0xc022302540)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2344 +0xd25
    sync.(*Once).doSlow(0x0?, 0x0?)
            C:/Program Files/Go/src/sync/once.go:74 +0xc2
    sync.(*Once).Do(...)
            C:/Program Files/Go/src/sync/once.go:65
    golang.org/x/tools/go/ssa.(*Package).Build(...)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2263
    golang.org/x/tools/go/ssa.(*Program).Build.func1(0x0?)
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2247 +0x4c
    created by golang.org/x/tools/go/ssa.(*Program).Build
            C:/Users/redacted/Documents/Go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2246 +0x19c
    

    The error goes away if I upgrade golang.org/x/tools:

    go-callvis> go get golang.org/x/tools
    go: downloading golang.org/x/tools v0.4.0
    go: downloading golang.org/x/mod v0.7.0
    go: downloading golang.org/x/sys v0.3.0
    go: upgraded golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 => v0.7.0
    go: upgraded golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f => v0.3.0
    go: upgraded golang.org/x/tools v0.1.12 => v0.4.0
    
  • Getting undeclared name when program builds perfectly

    Getting undeclared name when program builds perfectly

    Can someone help on that ? it doesn't make much sense to me

    $ go-callvis ./prog/cmd/alpha/run.go
    /src/git/prog/prog/cmd/alpha/run.go:499:31: undeclared name: queryHandler
    /src/git/prog/prog/cmd/alpha/run.go:500:32: undeclared name: queryHandler
    /src/git/prog/prog/cmd/alpha/run.go:501:32: undeclared name: mutationHandler
    /src/git/prog/prog/cmd/alpha/run.go:502:33: undeclared name: mutationHandler
    /src/git/prog/prog/cmd/alpha/run.go:503:32: undeclared name: commitHandler
    /src/git/prog/prog/cmd/alpha/run.go:504:31: undeclared name: alterHandler
    /src/git/prog/prog/cmd/alpha/run.go:548:35: undeclared name: graphqlProbeHandler
    /src/git/prog/prog/cmd/alpha/run.go:558:3: undeclared name: allowedMethodsHandler
    /src/git/prog/prog/cmd/alpha/run.go:558:25: undeclared name: allowedMethods
    /src/git/prog/prog/cmd/alpha/run.go:562:6: undeclared name: adminAuthHandler
    /src/git/prog/prog/cmd/alpha/run.go:564:28: undeclared name: getAdminMux
    /src/git/prog/prog/cmd/alpha/run.go:570:39: undeclared name: homeHandler
    /src/git/prog/prog/cmd/alpha/run.go:571:50: undeclared name: keywordHandler
    2022/12/08 09:15:20 packages contain errors
    

    They are in the same package so not sure what's going on. I also get

    no concrete method: func (*sync/atomic.Pointer[go/token.File]).CompareAndSwap(old *go/token.File, new *go/token.File) (swapped bool)
    
    goroutine 9005 [running]:
    golang.org/x/tools/go/ssa.(*Program).declaredFunc(0x1402d1a8140, 0x14032dbc120)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:124 +0x108
    golang.org/x/tools/go/ssa.(*Program).addMethod(0x100b83df8?, 0x14027533730, 0x14032d89bd0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:86 +0x148
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83df8?, 0x14027533720?}, 0x0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:173 +0x668
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83dd0?, 0x14004061a40?}, 0x0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:215 +0x4e4
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83e70?, 0x1400f86cc30?}, 0x1)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:228 +0x544
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83dd0?, 0x140040619d0?}, 0x0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:221 +0x500
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83df8?, 0x14024eec5d0?}, 0x0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:193 +0x40c
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83e98?, 0x14024ea3b18?}, 0x0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:233 +0x5fc
    golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83e20?, 0x1402521b000?}, 0x0)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:209 +0x28c
    golang.org/x/tools/go/ssa.(*Program).needMethodsOf(0x1402d1a8140?, {0x100b83e20?, 0x1402521b000?})
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/methods.go:145 +0xac
    golang.org/x/tools/go/ssa.(*Package).build(0x1402f38ee40)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2275 +0xd0
    sync.(*Once).doSlow(0x4d?, 0x1401d336dc0?)
    	/opt/homebrew/Cellar/go/1.19.3/libexec/src/sync/once.go:74 +0x104
    sync.(*Once).Do(...)
    	/opt/homebrew/Cellar/go/1.19.3/libexec/src/sync/once.go:65
    golang.org/x/tools/go/ssa.(*Package).Build(...)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2263
    golang.org/x/tools/go/ssa.(*Program).Build.func1(0x2f22203a22726944?)
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2247 +0x54
    created by golang.org/x/tools/go/ssa.(*Program).Build
    	/go/pkg/mod/golang.org/x/[email protected]/go/ssa/builder.go:2246 +0x180
    
  • Can't work on a program that doesn't have a main

    Can't work on a program that doesn't have a main

    I have a repo with different programs and they all use a function called run(), however the only way to run without a main seems to load tests when it's not what I want. How can I do it without looking at tests ?

A Go dependency graph visualization tool
A Go dependency graph visualization tool

godepgraph godepgraph is a program for generating a dependency graph of Go packages. Install go get github.com/kisielk/godepgraph Use For basic usage

Jan 7, 2023
Reload a specified go program automatically by monitoring a directory.

gowatcher A bash script to automatically reload a go program when .go or .html files change in the monitored directory. It uses inotify. Installation

Jul 7, 2020
Visualize call graph of a Go program using Graphviz
Visualize call graph of a Go program using Graphviz

go-callvis go-callvis is a development tool to help visualize call graph of a Go program using interactive view. Introduction The purpose of this tool

Dec 31, 2022
Visualize your Go data structures using graphviz

memviz How would you rather debug a data structure? "Pretty" printed Visual graph (*test.fib)(0xc04204a5a0)({ index: (int) 5, prev: (*test.fib)(0xc0

Dec 22, 2022
Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz
Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz

Ltree Visualizer A golang library to visualize postgres ltree type data using DOT language and Graphviz What is Ltree? Ltree is a data type which is u

Jun 12, 2022
Converts 'go mod graph' output into Graphviz's DOT language
Converts 'go mod graph' output into Graphviz's DOT language

modgv Converts 'go mod graph' output into GraphViz's DOT language. takes no options or arguments it reads the output generated by “go mod graph” on st

Dec 22, 2022
Slice graph uses graphviz in order to pretty print slices for you.

slicegraph Slice graph uses graphviz in order to make you understand what happens underneath your slices.

Sep 22, 2022
get windows system call number dynamically, it doesn't need the system call table.

GetSyscallID get windows system call number dynamically, it doesn't need the system call table. Try download go get github.com/akkuman/getsyscallid/cm

Jun 1, 2022
InkCaller is an API to call Ink. Each new call is independent and can be executing concurrently

inkcaller This library InkCaller is an API to call Ink. Each new call is independent and can be executing concurrently. A call will force the ink stat

Feb 8, 2022
Tool to visualize the graph of embedded structs in Go projects
Tool to visualize the graph of embedded structs in Go projects

Visualize a hierarchy of embedded Go structs This tool scans a directory of Go source code files to create a visualization of struct embedding in the

Nov 27, 2022
Go package for writing descriptions using the Graphviz DOT language
Go package for writing descriptions using the Graphviz DOT language

dot - little helper package in Go for the graphviz dot language

Nov 30, 2022
JSONL graph tools - Graph is represented as JSONL of nodes and edges.

JSONL graph tools - Graph is represented as JSONL of nodes and edges.

Sep 27, 2022
The DGL Operator makes it easy to run Deep Graph Library (DGL) graph neural network training on Kubernetes

DGL Operator The DGL Operator makes it easy to run Deep Graph Library (DGL) graph neural network distributed or non-distributed training on Kubernetes

Dec 19, 2022
Btc-globe - Visualize Bitcoin node locations using golang
Btc-globe - Visualize Bitcoin node locations using golang

btc-globe Visualize Bitcoin nodes by location using Golang

Jan 19, 2022
Parses the Graphviz DOT language in golang

Parses the Graphviz DOT language and creates an interface, in golang, with which to easily create new and manipulate existing graphs which can be writ

Dec 25, 2022
Parses the Graphviz DOT language in golang

Parses the Graphviz DOT language and creates an interface, in golang, with which to easily create new and manipulate existing graphs which can be writ

Dec 25, 2022
An ease to use finit state machine golang implementation.Turn any struct to a fsm with graphviz visualization supported.

go-fsm An ease to use finit state machine golang implementation.Turn any struct to a fsm with graphviz visualization supported. usage import github.co

Dec 26, 2021
This image is primarily used to ping/call a URL on regular intervals using Kubernetes (k8s) CronJob.

A simple webhook caller This image is primarily used to ping/call a URL on regular intervals using Kubernetes (k8s) CronJob. A sample job would look s

Nov 30, 2021