lastx / go-mod-grapher

An extension for Visual Studio Code to preview of go command: go mod graph.
https://marketplace.visualstudio.com/items?itemName=xmtt.go-mod-grapher
MIT License
2 stars 0 forks source link

Go Mod Grapher

An extension for Visual Studio Code to preview of go command: go mod graph.

screenshot1 screenshot2

HELP

The author is not a front-end engineer. This extension should be considered as a prototype, so experience may not be good. Hope some engineers can provide some optimizations.

Pre install

  1. Be sure that go command is in $PATH
  2. Turn Go Module on
  3. Install graphviz and make sure dot command is in $PATH
  4. [OPTION] Make sure that go mod graph is functionally normal without some downloading process

Installation

You can install this extension from the Visual Studio Marketplace.

Usage

Open preview

  1. Open the [Command Palette] then select “Graphviz: Open Preview to the Side”.
  2. Click icon on the editor panel to trigger

    View type

  3. Default view is the full view of go mod graph
  4. Select one mod, it will show the view of this dependency. It shows like go mod why [mod]

Manipulate preview

Action Gesture
Zoom in Mouse wheel up / +
Zoom out Mouse wheel down / -
Toggle 100% zoom Mouse double click / Space
Pan Mouse drag / Left / Right / Up / Down / A / D / W / S
Zoom to 100% 0
Move to center X

There are three zooming modes: Fixed, Fit and Auto Fit.

Export graph

To export the generated graph, click the “Export” button on the top right corner.

Configuration

Configuration Type Description
graphvizPreview.dotPath string | null null means to use the “dot” program in your PATH environment variable, or a string value to indicate the “dot” program you want to use.
graphvizPreview.engine "dot" | null The layout engine to use. null means to use the “dot” layout engine. Currently, only the “dot” engine is supported.

Make sure the extension can find the “dot” program. You can set graphvizPreview.dotPath option to the path of the dot executable, or make sure the directory containing the dot program is in your PATH environment variable.

To set the graphvizPreview.dotPath option, go to File → Preference → Settings.

Acknowledgement

  1. The base code is forked from Graphviz-Preview, which is a extension to preview Graphviz (DOT) files
  2. The code in screenshot is Golong web framework gin-gonic/gin
  3. The icon of this extension is download from flaticon
  4. Add new lib to save graph data structure: graphlib