govisual

package module
v0.0.0-...-8c72f0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 11 Imported by: 0

README

govisual

Visualize golang project dependencies.

installation

First install graphviz.

eg. for macos, run

brew instal graphviz

then,

go install github.com/liguangsheng/govisual/...

usage

Usage of govisual:
  -all
    	include all subdirectory
  -host-as-org
    	include all subdirectory
  -hostasorg string
    	include organization packages
  -module string
    	custom module name
  -org
    	include all subdirectory
  -sys
    	include go sdk packages
  -templates value
    	custom template files
  -third
    	include third party packages

example

govisual <path-to-your-go-project>

generate png file with graphviz

govisual <path> | dot -Tpng -o /tmp/graph.png
visual for grpc-go
$ govisual -host-as-org  -org | dot -Tpng -o grpc-go.png

visual for pingcap/tidb/table/tables
$ govisual table/tables | dot -Tpng -o tidb-table-tables.png

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(v *Visualization, filenames ...string) string

Types

type Config

type Config struct {
	RootPath   string // project root path
	TargetPath string // target directory path, relative to RootPath
	Module     string // project module name
	All        bool   // parse all subdirectories
	SysPkg     bool   // include go sdk packages
	ThirdPkg   bool   // include third party packages
	OrgPkg     bool   // include same organization packages
	HostAsOrg  bool   // use host as organization
}

type Digraph

type Digraph struct {
	Nodes map[string]*Node
	Edges map[string]*Edge
	// contains filtered or unexported fields
}

func NewDigraph

func NewDigraph() *Digraph

func (*Digraph) Edge

func (g *Digraph) Edge(from, to value)

Edge add a edge To Digraph

func (*Digraph) HasFrom

func (g *Digraph) HasFrom(hash string) bool

HasFrom returns true if Digraph contains From node

func (*Digraph) Node

func (g *Digraph) Node(v value) *Node

Node returns node From Digraph, if not exist, add it.

type Edge

type Edge struct {
	From, To *Node
	Weight   int
}

type ImportType

type ImportType uint
const (
	Sys ImportType = iota
	Third
	Org
	Self
)

type Node

type Node struct {
	Value   value
	In, Out int
}

type Package

type Package struct {
	FullName     string
	SimpleName   string
	Type         ImportType
	RelativePath string
}

func (Package) Hash

func (p Package) Hash() string

type Visualization

type Visualization struct {
	Config  Config
	Digraph *Digraph
}

func New

func New(c Config) (*Visualization, error)

func (*Visualization) Parse

func (p *Visualization) Parse(root string) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL