###### tags: `Golang Package` # Memviz 將結構變成可視化圖表 ## example ```go= type tree struct { id int left *tree right *tree } func main() { root := &tree{ id: 0, left: &tree{ id: 1, }, right: &tree{ id: 2, }, } leaf := &tree{ id: 3, } root.left.right = leaf root.right.left = leaf buf := &bytes.Buffer{} memviz.Map(buf, &root) err := ioutil.WriteFile("example-tree-data", buf.Bytes(), 0644) if err != nil { panic(err) } } ``` 運行後會得到一個檔案 example-tree-data 再透過`graphviz`產生圖片 ``` dot -Tpng example-tree-data -o diagram.png ``` 結果  ## 用Item的結構  [大圖](https://i.imgur.com/zBP5QzD.png) # [Graphviz](https://zh.wikipedia.org/wiki/Graphviz) 用於繪製DOT語言指令碼描述的圖形 ``` graph graphname { a -- b -- c; b -- d; } ```  [更多範例](http://www.graphviz.org/gallery/) [貝爾實驗室](https://www.bell-labs.com/#gref) [wiki](https://en.wikipedia.org/wiki/Bell_Labs)  {%hackmd theme-dark %}
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up