10 examples of 'golang readstring' in Go

Every line of 'golang readstring' 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
146func (r *reader) ReadString(nullable bool) (*string, error) {
147 _, r.tmpErr = r.reader.Read(r.bytes)
148 if r.tmpErr != nil {
149 return nil, r.tmpErr
150 }
151
152 if (r.bytes[0] & 0x7F) == 0 {
153 if r.bytes[0] == 0x80 {
154 if nullable {
155 return nil, nil
156 }
157 return &r.tmpStr, nil
158 }
159
160 _, r.tmpErr = r.reader.Read(r.bytes)
161 if r.tmpErr != nil {
162 return nil, r.tmpErr
163 }
164
165 if r.bytes[0] == 0x80 {
166 return &r.tmpStr, nil
167 } else if nullable && r.bytes[0] == 0x00 {
168 _, r.tmpErr = r.reader.Read(r.bytes)
169 if r.tmpErr != nil {
170 return nil, r.tmpErr
171 }
172
173 if r.bytes[0] == 0x80 {
174 return &r.tmpStr, nil
175 }
176 }
177 r.tmpErr = ErrR9
178 return nil, r.tmpErr
179 }
180
181 for {
182 if (r.bytes[0] & 0x80) > 0 {
183 r.strBuf.WriteByte(r.bytes[0] & 0x7F)
184 break
185 }
186 r.strBuf.WriteByte(r.bytes[0])
187 _, r.tmpErr = r.reader.Read(r.bytes)
188 if r.tmpErr != nil {
189 return nil, r.tmpErr
190 }
191 }
192
193 r.tmpStr = r.strBuf.String()
194 r.strBuf.Reset()
195 return &r.tmpStr, nil
196}
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

227func (player *Player) ReadString() (s string, err error) {
228 length, err := player.ReadVarInt()
229 if err != nil {
230 return "", err
231 }
232 buffer := make([]byte, length)
233 _, err = io.ReadFull(player.io.rdr, buffer)
234 if err != nil {
235 return "", err
236 }
237 return string(buffer), nil
238}
358func (p *parser) readString() (string, error) {
359 b, err := p.readBytes()
360 if err != nil {
361 return "", err
362 }
363 return string(b), nil
364}
123func (s *ArgsVar) ReadString(i int) string {
124 if len(s.args) <= i {
125 return ""
126 }
127 return s.args[i].(string)
128}
24func (conn *Conn) ReadString(n int) string {
25 return string(conn.ReadBytes(n))
26}
222func (b *Buffer) ReadString(length int) string {
223 return string(b.ReadSlice(length))
224}
113func ReadString(t Translator, v string) (C, error) {
114 return t.ReadFrom(
115 strings.NewReader(v),
116 )
117}
360func (b *Buffer) ReadString(n int) (s string, err error) {
361 if (b.seek + n) > b.pos {
362 err = ErrIOEOF
363 return
364 }
365
366 s = string(b.buf[b.seek:(b.seek + n)])
367 b.seek += n
368 return
369}
110func readString(r io.Reader) ([]byte, error) {
111 size, err := readCompactSize(r)
112 if err != nil {
113 return nil, err
114 }
115
116 buf := make([]byte, int(size))
117 _, err = io.ReadFull(r, buf)
118 if err != nil {
119 return nil, err
120 }
121
122 return buf, nil
123}
213func readString(r io.Reader) (string, error) {
214 len, err := readLong(r)
215 if err != nil {
216 return "", err
217 }
218 bb := make([]byte, len)
219 _, err = io.ReadFull(r, bb)
220 if err != nil {
221 return "", err
222 }
223 return string(bb), nil
224}

Related snippets