mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-10 02:20:28 +00:00
BitTorrent peer write test
This commit is contained in:
1 parent
41ff983b73
commit
03fbdcda60
15 files changed
+649
-188
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Age uint32
|
||||
Sex byte
|
||||
Name [20]byte
|
||||
}
|
||||
|
||||
type Buffer struct {
|
||||
buf []byte
|
||||
limit int
|
||||
}
|
||||
|
||||
func NewBuffer(buf []byte) *Buffer {
|
||||
return &Buffer{
|
||||
buf: buf,
|
||||
limit: 0,
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
user := &User{1, 2, [20]byte{}}
|
||||
buf := new(bytes.Buffer)
|
||||
binary.Write(buf, binary.LittleEndian, user)
|
||||
fmt.Println(buf.Bytes())
|
||||
}
|
||||
|
||||
/*func (buffer Buffer) ReadByte() (byte, error) {
|
||||
|
||||
}
|
||||
|
||||
func (buffer Buffer) ReadByte() (byte, error)() {
|
||||
|
||||
}
|
||||
*/
|
||||
Reference in new issue
Block a user