本文整理匯總了Golang中github.com/mdlayher/aoe.Header.UnmarshalBinary方法的典型用法代碼示例。如果您正苦於以下問題:Golang Header.UnmarshalBinary方法的具體用法?Golang Header.UnmarshalBinary怎麽用?Golang Header.UnmarshalBinary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mdlayher/aoe.Header
的用法示例。
在下文中一共展示了Header.UnmarshalBinary方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testRequest
// testRequest performs a single AoE request using the input request
// header and returns a single AoE response.
func testRequest(t *testing.T, req *aoe.Header) *aoe.Header {
recv, send, run, done := testAoEServer(t)
defer done()
reqb, err := req.MarshalBinary()
if err != nil {
t.Fatalf("failed to marshal request AoE header: %v", err)
}
reqf := ðernet.Frame{
Payload: reqb,
}
reqfb, err := reqf.MarshalBinary()
if err != nil {
t.Fatalf("failed to marshal request Ethernet frame: %v", err)
}
if _, err := send.Write(reqfb); err != nil {
t.Fatalf("failed to write request to server: %v", err)
}
if err := run(); err != nil {
t.Fatalf("failed to run server: %v", err)
}
b, err := ioutil.ReadAll(recv)
if err != nil {
t.Fatalf("failed to read server response: %v", err)
}
resf := new(ethernet.Frame)
if err := resf.UnmarshalBinary(b); err != nil {
t.Fatalf("failed to unmarshal response Ethernet frame: %v", err)
}
resh := new(aoe.Header)
if err := resh.UnmarshalBinary(resf.Payload); err != nil {
t.Fatalf("failed to unmarshal response AoE header: %v", err)
}
return resh
}