github.com/nxtrace/NTrace-core@v1.3.1-0.20240513132635-39169291e8c9/printer/easy.go (about)

     1  package printer
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/nxtrace/NTrace-core/trace"
     7  )
     8  
     9  func EasyPrinter(res *trace.Result, ttl int) {
    10  	for i := range res.Hops[ttl] {
    11  		if res.Hops[ttl][i].Address == nil {
    12  			fmt.Printf("%d|*||||||\n", ttl+1)
    13  			continue
    14  		}
    15  		applyLangSetting(&res.Hops[ttl][i]) // 应用语言设置
    16  		fmt.Printf(
    17  			"%d|%s|%s|%.2f|%s|%s|%s|%s|%s|%s|%.4f|%.4f\n",
    18  			ttl+1,
    19  			res.Hops[ttl][i].Address.String(),
    20  			res.Hops[ttl][i].Hostname,
    21  			float64(res.Hops[ttl][i].RTT.Microseconds())/1000,
    22  			res.Hops[ttl][i].Geo.Asnumber,
    23  			res.Hops[ttl][i].Geo.Country,
    24  			res.Hops[ttl][i].Geo.Prov,
    25  			res.Hops[ttl][i].Geo.City,
    26  			res.Hops[ttl][i].Geo.District,
    27  			res.Hops[ttl][i].Geo.Owner,
    28  			res.Hops[ttl][i].Geo.Lat,
    29  			res.Hops[ttl][i].Geo.Lng,
    30  		)
    31  	}
    32  }