-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.go
45 lines (40 loc) · 774 Bytes
/
type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package bytestruct
import (
"encoding/binary"
"github.com/HarryWang29/bytestruct/runtime"
"github.com/HarryWang29/bytestruct/types"
"unsafe"
)
type ByteStruct struct {
s *types.Stream
order binary.ByteOrder
option *types.Option
}
func NewWriter(order binary.ByteOrder, optionFunc ...OptionFunc) *ByteStruct {
bs := &ByteStruct{
order: order,
option: &types.Option{
Order: order,
},
}
for _, o := range optionFunc {
o(bs.option)
}
return bs
}
func NewReader(order binary.ByteOrder, optionFunc ...OptionFunc) *ByteStruct {
bs := &ByteStruct{
order: order,
option: &types.Option{
Order: order,
},
}
for _, o := range optionFunc {
o(bs.option)
}
return bs
}
type emptyInterface struct {
typ *runtime.Type
ptr unsafe.Pointer
}