structgraph

package module
v0.0.0-...-b665193 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(in interface{}, opts ...Option) string

func GenPngFromApi

func GenPngFromApi(str, filename string) (err error)

func GenPngFromQuickChartApi

func GenPngFromQuickChartApi(str, filename string) (err error)

func GenPuml

func GenPuml(app interface{}, filename string, opts ...Option) (err error)

Types

type Option

type Option func(d *drawer)

func WithItfMethod

func WithItfMethod() Option

func WithScope

func WithScope(path ...string) Option

Jump to

Keyboard shortcuts

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