欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

GoLang調(diào)用鏈可視化go-callvis使用介紹

 更新時(shí)間:2023年02月02日 14:45:06   作者:raoxiaoya  
與鏈路追蹤(Tracing)不同,Tracing關(guān)注復(fù)雜的分布式環(huán)境中各個(gè)服務(wù)節(jié)點(diǎn)間的調(diào)用關(guān)系,主要用于服務(wù)治理。而我們本次探索的代碼調(diào)用鏈路則是代碼方法級(jí)別的調(diào)用關(guān)系,主要用于代碼設(shè)計(jì)

本文介紹一款工具 go-callvis,它能夠?qū)?Go 代碼的調(diào)用關(guān)系可視化出來(lái),并提供了可交互式的 web 服務(wù)。

go get -u github.com/ofabry/go-callvis
在windows系統(tǒng)上并沒(méi)有自動(dòng)安裝,需要進(jìn)入下載的目錄go install
在linux系統(tǒng)上自動(dòng)安裝了

> go-callvis

go-callvis: visualize call graph of a Go program.

Usage:

  go-callvis [flags] package

  Package should be main package, otherwise -tests flag must be used.

Flags:

  -debug
        Enable verbose log.
  -file string
        output filename - omit to use server mode
  -focus string
        Focus specific package using name or import path. (default "main")
  -format string
        output file format [svg | png | jpg | ...] (default "svg")
  -graphviz
        Use Graphviz's dot program to render images.
  -group string
        Grouping functions by packages and/or types [pkg, type] (separated by comma) (default "pkg")
  -http string
        HTTP service address. (default ":7878")
  -ignore string
        Ignore package paths containing given prefixes (separated by comma)
  -include string
        Include package paths with given prefixes (separated by comma)
  -limit string
        Limit package paths to given prefixes (separated by comma)
  -minlen uint
        Minimum edge length (for wider output). (default 2)
  -nodesep float
        Minimum space between two adjacent nodes in the same rank (for taller output). (default 0.35)
  -nointer
        Omit calls to unexported functions.
  -nostd
        Omit calls to/from packages in standard library.
  -skipbrowser
        Skip opening browser.
  -tags build tags
        a list of build tags to consider satisfied during the build. For more information about build tags, see the description of buil
d constraints in the documentation for the go/build package
  -tests
        Include test code.
  -version
        Show version and exit.

依賴(lài)

  • Go 1.17+
  • Graphviz (可選,當(dāng)工具指定了 -graphviz 時(shí)需要)

測(cè)試代碼

package main
import (
	"log"
	"net"
)
func main() {
	// Part 1: create a listener
	l, err := net.Listen("tcp", ":8000")
	if err != nil {
		log.Fatalf("Error listener returned: %s", err)
	}
	defer l.Close()
	for {
		// Part 2: accept new connection
		c, err := l.Accept()
		if err != nil {
			log.Fatalf("Error to accept new connection: %s", err)
		}
		// Part 3: create a goroutine that reads and write back data
		go func() {
			log.Printf("TCP session open")
			defer c.Close()
			for {
				d := make([]byte, 1024)
				// Read from TCP buffer
				_, err := c.Read(d)
				if err != nil {
					log.Printf("Error reading TCP session: %s", err)
					break
				}
				log.Printf("reading data from client: %s\n", string(d))
				// write back data to TCP client
				_, err = c.Write(d)
				if err != nil {
					log.Printf("Error writing TCP session: %s", err)
					break
				}
			}
		}()
	}
}

在linux上可以正常運(yùn)行,windows上會(huì)報(bào)錯(cuò)

> go-callvis main67.go
2022/09/21 15:28:50 http serving at http://localhost:7878

go-callvis 默認(rèn)將代碼調(diào)用關(guān)系存儲(chǔ)成 svg 格式的圖形。

在瀏覽器中訪問(wèn) http://localhost:7878

點(diǎn)擊上面的 log 模塊,將會(huì)進(jìn)入 log 模塊的代碼調(diào)用交互圖中

它主要是作用是清晰的列出了包與包之間的依賴(lài)以及調(diào)用關(guān)系,用來(lái)理解項(xiàng)目的大致架構(gòu)。

到此這篇關(guān)于GoLang調(diào)用鏈可視化go-callvis使用介紹的文章就介紹到這了,更多相關(guān)Go callvis內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 在Golang中正確的修改HTTPRequest的Host的操作方法

    在Golang中正確的修改HTTPRequest的Host的操作方法

    我們工作中經(jīng)常需要通過(guò)HTTP請(qǐng)求Server的服務(wù),比如腳本批量請(qǐng)求接口跑數(shù)據(jù),由于一些網(wǎng)關(guān)策略,部分Server會(huì)要求請(qǐng)求中Header里面附帶Host參數(shù),所以本文給大家介紹了如何在Golang中正確的修改HTTPRequest的Host,需要的朋友可以參考下
    2023-12-12
  • Goland 的安裝及激活教程(window、linux下安裝)

    Goland 的安裝及激活教程(window、linux下安裝)

    這篇文章主要介紹了Golang Goland 的安裝及激活詳細(xì)教程,包括window下安裝goland和linux下安裝goland,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-10-10
  • Go在GoLand中引用github.com中的第三方包具體步驟

    Go在GoLand中引用github.com中的第三方包具體步驟

    這篇文章主要給大家介紹了關(guān)于Go在GoLand中引用github.com中第三方包的具體步驟,文中通過(guò)圖文介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Go具有一定的參考價(jià)值,需要的朋友可以參考下
    2024-01-01
  • go通過(guò)編碼縮短字符串的長(zhǎng)度實(shí)現(xiàn)方法步驟

    go通過(guò)編碼縮短字符串的長(zhǎng)度實(shí)現(xiàn)方法步驟

    這篇文章主要為大家介紹了go通過(guò)編碼縮短字符串的長(zhǎng)度實(shí)現(xiàn)方法步驟,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2024-01-01
  • Go語(yǔ)言新寵:pdqsort排序算法的完美打造

    Go語(yǔ)言新寵:pdqsort排序算法的完美打造

    pdqsort是一種新的排序算法,特別適用于Go語(yǔ)言,它是由Go語(yǔ)言團(tuán)隊(duì)開(kāi)發(fā)的,旨在提供高效且穩(wěn)定的排序算法,pdqsort采用了一種分治的策略,將數(shù)組分成小塊進(jìn)行排序,然后再合并這些塊,需要的朋友可以參考下
    2023-10-10
  • Goland的設(shè)置與配置全過(guò)程

    Goland的設(shè)置與配置全過(guò)程

    這篇文章主要介紹了Goland的設(shè)置與配置全過(guò)程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • go中import包的大坑解決方案

    go中import包的大坑解決方案

    最近開(kāi)始使用Go/GoLand 在import 自定義包時(shí)出現(xiàn)各種狀況,本文就介紹一下go中import包的大坑解決方案,具有一定的參考價(jià)值,感興趣 可以了解一下
    2022-06-06
  • golang中對(duì)

    golang中對(duì)"引用傳遞"的誤解

    這篇文章主要介紹了golang中對(duì)“引用傳遞”的誤解,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-06-06
  • 關(guān)于Gin框架中的Cookie和Session的使用方法

    關(guān)于Gin框架中的Cookie和Session的使用方法

    為了實(shí)現(xiàn)跨請(qǐng)求的數(shù)據(jù)共享,我們可以使用Cookie和Session,本文將結(jié)合實(shí)際案例,詳細(xì)介紹在Go語(yǔ)言的Gin框架中如何使用Cookie和Session,并通過(guò)代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
    2024-10-10
  • Go語(yǔ)言學(xué)習(xí)教程之聲明語(yǔ)法(譯)

    Go語(yǔ)言學(xué)習(xí)教程之聲明語(yǔ)法(譯)

    Golang 就是類(lèi)C的語(yǔ)法,下面這篇文章主要給大家介紹了關(guān)于Go語(yǔ)言學(xué)習(xí)教程之聲明語(yǔ)法的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-11-11

最新評(píng)論