MCPcopy
hub / github.com/google/gopacket / ExampleSerializeBuffer

Function ExampleSerializeBuffer

writer_test.go:66–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64}
65
66func ExampleSerializeBuffer() {
67 b := NewSerializeBuffer()
68 fmt.Println("1:", b.Bytes())
69 bytes, _ := b.PrependBytes(3)
70 copy(bytes, []byte{1, 2, 3})
71 fmt.Println("2:", b.Bytes())
72 bytes, _ = b.AppendBytes(2)
73 copy(bytes, []byte{4, 5})
74 fmt.Println("3:", b.Bytes())
75 bytes, _ = b.PrependBytes(1)
76 copy(bytes, []byte{0})
77 fmt.Println("4:", b.Bytes())
78 bytes, _ = b.AppendBytes(3)
79 copy(bytes, []byte{6, 7, 8})
80 fmt.Println("5:", b.Bytes())
81 b.Clear()
82 fmt.Println("6:", b.Bytes())
83 bytes, _ = b.PrependBytes(2)
84 copy(bytes, []byte{9, 9})
85 fmt.Println("7:", b.Bytes())
86 // Output:
87 // 1: []
88 // 2: [1 2 3]
89 // 3: [1 2 3 4 5]
90 // 4: [0 1 2 3 4 5]
91 // 5: [0 1 2 3 4 5 6 7 8]
92 // 6: []
93 // 7: [9 9]
94}

Callers

nothing calls this directly

Calls 5

BytesMethod · 0.95
PrependBytesMethod · 0.95
AppendBytesMethod · 0.95
ClearMethod · 0.95
NewSerializeBufferFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…