10 examples of 'golang io.reader' in Go

Every line of 'golang io.reader' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
776func (i *RemoveBlock) Read(buf *bytes.Buffer) {
777 i.EntityID = ReadLong(buf)
778 i.X = ReadInt(buf)
779 i.Z = ReadInt(buf)
780 i.Y = ReadByte(buf)
781}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

115func (c *Conn) Read(b []byte) (int, error) {
116 if c.r == nil {
117 if err := c.initReader(); err != nil {
118 return 0, err
119 }
120 }
121 return c.r.Read(b)
122}
212func (t *endpointClient) Read(buf []byte) (int, error) {
213 src, ok := <-t.read
214 if !ok {
215 return 0, errorTerminated
216 }
217 n := copy(buf, src)
218 return n, nil
219}
850func (b *Batch) Reader() BatchReader {
851 if len(b.data) == 0 {
852 b.init(batchHeaderLen)
853 }
854 return b.data[batchHeaderLen:]
855}
63func (wc *WebsocketServerConn) Read(p []byte) (n int, err error) {
64 if wc.r == nil {
65 _, wc.r, err = wc.Ws.NextReader()
66
67 if err != nil {
68 fmt.Println(err)
69 return 0, err
70 }
71 }
72
73 n, err = wc.r.Read(p)
74 if err == io.EOF {
75 wc.r = nil
76 }
77
78 return
79}
1134func (i *MobEquipment) Read(buf *bytes.Buffer) {
1135 i.EntityID = ReadLong(buf)
1136 i.Item = new(Item)
1137 i.Item.Read(buf)
1138 i.Slot = ReadByte(buf)
1139 i.SelectedSlot = ReadByte(buf)
1140}
91func (b *Boolean) ReadFrom(r io.Reader) (n int64, err error) {
92 v, err := readByte(r)
93 if err != nil {
94 return 1, err
95 }
96
97 *b = v != 0
98 return 1, nil
99}
94func (mr *mmapReader) Read(buf []byte) (int, error) {
95 if mr.offset > len(mr.Data) {
96 return 0, io.EOF
97 }
98 n := copy(buf, mr.Data[mr.offset:])
99 mr.offset += n
100 if n < len(buf) {
101 return n, io.EOF
102 }
103 return n, nil
104}
44func (ipc *icmpPacketConn) read(buf []byte) (int, net.Addr, error) {
45 return ipc.c.ReadFrom(buf)
46}
64func (cf *ChunkFile) Read(data []byte) (int, error) {
65 return io.ReadFull(cf.file, data)
66}

Related snippets