本文整理匯總了Golang中github.com/h8liu/d8/printer.Interface類的典型用法代碼示例。如果您正苦於以下問題:Golang Interface類的具體用法?Golang Interface怎麽用?Golang Interface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Interface類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PrintTo
func (self *Packet) PrintTo(p printer.Interface) {
p.Printf("#%d %s", self.Id, flagString(self.Flag))
p.Printf("ques %v", self.Question)
self.Answer.PrintNameTo(p, "answ")
self.Authority.PrintNameTo(p, "auth")
self.Addition.PrintNameTo(p, "addi")
}
示例2: printTimeTaken
func (self *Exchange) printTimeTaken(p printer.Interface) {
d := self.Recv.Timestamp.Sub(self.Send.Timestamp)
n := d.Nanoseconds()
var s string
if n < 1e3 {
s = fmt.Sprintf("%dns", n)
} else if n < 1e6 {
s = fmt.Sprintf("%.1fus", float64(n)/1e3)
} else if n < 1e9 {
s = fmt.Sprintf("%.2fms", float64(n)/1e6)
} else {
s = fmt.Sprintf("%.3fs", float64(n)/1e9)
}
p.Printf("(in %v)", s)
}
示例3: printSend
func (self *Exchange) printSend(p printer.Interface) {
p.Printf("%s {", self.Query.String())
p.ShiftIn()
switch self.PrintFlag {
case PrintAll:
p.Print("send {")
p.ShiftIn()
self.Send.PrintTo(p)
p.ShiftOut("}")
case PrintReply:
// do nothing
default:
panic("unknown print flag")
}
}
示例4: PrintNameTo
func (self Section) PrintNameTo(p printer.Interface, name string) {
if self == nil {
return
}
if len(self) == 0 {
return
}
if len(self) == 1 {
p.Printf("%s %v", name, self[0])
} else {
p.Printf("%s {", name)
p.ShiftIn()
self.PrintTo(p)
p.ShiftOut("}")
}
}
示例5: PrintTo
func (self *Info) PrintTo(p printer.Interface) {
if len(self.Cnames) > 0 {
p.Print("cnames {")
p.ShiftIn()
for _, r := range self.Cnames {
p.Printf("%v -> %v", r.Domain, rdata.ToDomain(r.Rdata))
}
p.ShiftOut("}")
}
if len(self.Results) == 0 {
p.Print("(unresolvable)")
} else {
p.Print("ips {")
p.ShiftIn()
for _, r := range self.Results {
d := r.Domain
ip := rdata.ToIPv4(r.Rdata)
if d.Equal(self.Domain) {
p.Printf("%v", ip)
} else {
p.Printf("%v(%v)", ip, d)
}
}
p.ShiftOut("}")
}
if len(self.NameServers) > 0 {
p.Print("servers {")
p.ShiftIn()
for _, ns := range self.NameServers {
p.Printf("%v", ns)
}
p.ShiftOut("}")
}
if len(self.Records) > 0 {
p.Print("records {")
p.ShiftIn()
for _, rr := range self.Records {
p.Printf("%v", rr.Digest())
}
p.ShiftOut("}")
}
}
示例6: printRecv
func (self *Exchange) printRecv(p printer.Interface) {
switch self.PrintFlag {
case PrintAll:
if self.Recv != nil {
p.Print("recv {")
p.ShiftIn()
self.Recv.PrintTo(p)
p.ShiftOut("}")
}
if self.Error != nil {
p.Printf("error %v", self.Error)
}
case PrintReply:
if self.Recv != nil {
self.Recv.Packet.PrintTo(p)
self.printTimeTaken(p)
}
if self.Error != nil {
p.Printf("error %v", self.Error)
}
default:
panic("unknown print flag")
}
p.ShiftOut("}")
}
示例7: PrintTo
func (self *Message) PrintTo(p printer.Interface) {
p.Printf("@%s", addrString(self.RemoteAddr))
self.Packet.PrintTo(p)
}
示例8: PrintTo
func (self Section) PrintTo(p printer.Interface) {
for _, rr := range self {
p.Print(rr)
}
}