MCPcopy
hub / github.com/micro/go-micro / WriteNetString

Function WriteNetString

codec/protorpc/netstring.go:10–17  ·  view source on GitHub ↗

WriteNetString writes data to a big-endian netstring on a Writer. Size is always a 32-bit unsigned int.

(w io.Writer, data []byte)

Source from the content-addressed store, hash-verified

8// WriteNetString writes data to a big-endian netstring on a Writer.
9// Size is always a 32-bit unsigned int.
10func WriteNetString(w io.Writer, data []byte) (written int, err error) {
11 size := make([]byte, 4)
12 binary.BigEndian.PutUint32(size, uint32(len(data)))
13 if written, err = w.Write(size); err != nil {
14 return
15 }
16 return w.Write(data)
17}
18
19// ReadNetString reads data from a big-endian netstring.
20func ReadNetString(r io.Reader) (data []byte, err error) {

Callers 1

WriteMethod · 0.85

Calls 1

WriteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…