Go mod graph visualization — gmchart



Previous buildgolangA problem was that the dependent package version was clearly specified, and the version number was automatically raised during construction. I didn’t know why at that time. I know there’s one in the backgo mod graphThe command can list all dependencies. After trying, it is not intuitive at all. It has to be copied to the text editor to retrieve information.

So I checked the relevant tools on the Internet.

Other tools

Retrieve go module dependency visualization

There are still many tools on the Internet. Most of the options aregraphvizechart, or draw pictures, I tried a few.

graphvizThis tool is very powerful, but it needs to be installed through other channels, and the generated SVG is not so readable, especially after there are more dependent packages, such as the following:

Go mod graph visualization -- gmchart

So I turned to echart,

Wow, it looks good, the mouse hover feedback is also good, and the color matching is also very bright.

Go mod graph visualization -- gmchart

The echart scheme is beautiful, but it doesn’t work. Svg I can also search the package name, but echart does not display the package name.


OK, make complaints about Tucao make complaints about it. Today I’d like to introduce you togo mod graphVisualization tools——gmchart


github: github.com/PaulXu-cn/go-mod-graph-…


go get -u github.com/PaulXu-cn/go-mod-graph-chart/gmchart

Check the installation. The following is the success

gmchart --help

Usage of ~\go\bin\gmchart:
  -debug int
        is debug model
  -keep int
        start http server not exit


Enter the golang project and enter the command:

go mod graph | gmchart

The browser will be opened automatically. If not, just manually

visit127.0.0.1:60306Can see

Go mod graph visualization -- gmchart

You can see that it forms a dependency tree. You can know which layer of a package is introduced, which is very intuitive. The web page is an SVG. It’s also very convenient for you to find a packagectr+FYou can retrieve it.


After looking for so long, why don’t you have a tool?

I thought,visualizationThe front-end is good at it. The front-end doesn’t need itgolangAh, there are few, yesGolangThe front end of the is also rightgo mod graphWe are less interested in this function, so this tool can only be done by our back-end


Other programmes

This work adoptsCC agreement, reprint must indicate the author and the link to this article