Skip to content

generate struct relation graph in graphviz of your application

License

Notifications You must be signed in to change notification settings

wanzirong/structgraph

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Struct Graph

generate struct relation graph of your application

Mentions

Usage

import "github.com/Just-maple/structgraph"

Example

func MakeApplication() Application {
	listener, err := net.Listen("tcp", ":8080")
	if err != nil {
		panic(err)
	}
	src := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", "root", "Aa123456", "0.0.0.0", 3306, "mysql")
	sqlDB, err := sql.Open("mysql", src)
	if err != nil {
		panic(err)
	}
	db := &database.SqlStore{DB: sqlDB}
	a := app.Application{
		Server: listener,
		Service: app.Service{
			User: &svc_impls.User{
				UserDao: dao_impls.NewUserDao(),
				DB:      db,
			},
			Book: &svc_impls.Book{
				BookDao: dao_impls.NewBookDao(),
				DB:      db,
			},
			Pay: &svc_impls.Pay{Client: sdk.NewPayClient()},
		},
	}
	return a
}

func Draw() {
	app := MakeApplication()
	ret := structgraph.Draw(app)

}

draw ret with graphviz dot

or use googleapi

structgraph.GenPngFromApi(ret, "test.png")

png

This is another example with a go-micro server

micro

About

generate struct relation graph in graphviz of your application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%