-
Notifications
You must be signed in to change notification settings - Fork 0
/
write.go
37 lines (28 loc) · 670 Bytes
/
write.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
// This file is subject to a 1-clause BSD license.
// Its contents can be found in the enclosed LICENSE file.
package mitosis
import (
"encoding/binary"
"io"
)
func writeString(w io.Writer, v string) {}
func writeU32(w io.Writer, v uint32) {
check(binary.Write(w, endian, v))
}
func writeU64(w io.Writer, v uint64) {
check(binary.Write(w, endian, v))
}
func writeRaw(w io.Writer, v []byte) {
_, err := w.Write(v)
check(err)
}
func writeByteSlice(w io.Writer, v []byte) {
writeU32(w, uint32(len(v)))
writeRaw(w, v)
}
func writeStringSlice(w io.Writer, v []string) {
writeU32(w, uint32(len(v)))
for i := range v {
writeByteSlice(w, []byte(v[i]))
}
}