10 examples of 'golang readline' in Go

Every line of 'golang readline' 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
707func readLine(b []byte, i int) (p []byte, j int) {
708 _ = b[len(b)-1]
709 for j = i; j < len(b); j++ {
710 if b[j] == '\n' {
711 break
712 }
713 }
714 j++
715 p = b[i:j]
716 return
717}
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

36func readLine(rd *bufio.Reader) ([]byte, error) {
37 line, isPrefix, err := rd.ReadLine()
38 if err != nil {
39 return line, err
40 }
41 if isPrefix {
42 return line, errReaderTooSmall
43 }
44 return line, nil
45}
170func readLine(r *bufio.Reader, lineBuf *[]byte) bool {
171 if !readBytesUntil(r, '\n', lineBuf) {
172 return false
173 }
174 line := *lineBuf
175 if len(line) == 0 {
176 return true
177 }
178 lastN := len(line) - 1
179 if line[lastN] == '\r' {
180 line = line[:lastN]
181 }
182 *lineBuf = line
183 return true
184}
118func (ed *Editor) ReadLine() (string, error) {
119 return ed.app.ReadCode()
120}
140func (r *reader) readLine() string {
141 r.buf = r.buf[:0]
142 var c byte
143 for r.err == nil {
144 c, r.err = r.r.ReadByte()
145 if c == '\n' {
146 break
147 }
148 r.buf = append(r.buf, c)
149 }
150 return string(r.buf)
151}
214func (tail *Tail) readLine() (string, error) {
215 tail.lk.Lock()
216 line, err := tail.reader.ReadString('\n')
217 tail.lk.Unlock()
218 if err != nil {
219 // Note ReadString "returns the data read before the error" in
220 // case of an error, including EOF, so we return it as is. The
221 // caller is expected to process it if err is EOF.
222 return line, err
223 }
224
225 line = strings.TrimRight(line, "\n")
226
227 return line, err
228}
336func (s *session) readLine() (string, error) {
337 if s.srv.Timeout > 0 {
338 s.conn.SetReadDeadline(time.Now().Add(s.srv.Timeout))
339 }
340
341 line, err := s.br.ReadString('\n')
342 if err != nil {
343 return "", err
344 }
345 line = strings.TrimSpace(line) // Strip trailing \r\n
346
347 if Debug {
348 log.Println(s.remoteIP, "READ ", line)
349 }
350
351 return line, err
352}
505func readLine(data []byte, offset int) (bool, string, int) {
506 q := bytes.Index(data[offset:], []byte("\r\n"))
507 if q == -1 {
508 return false, "", 0
509 }
510 return true, string(data[offset : offset+q]), offset + q + 2
511}
17func readLine(r *bufio.Reader) (string, error) {
18 line, err := r.ReadString('\n')
19 if err != nil {
20 return "", err
21 }
22 if len(line) < 3 {
23 return "", ErrProtocol
24 }
25 return line, nil
26}
79func (f *File) readLine(maxBytes int) (string, error) {
80 var buf bytes.Buffer
81 numBytesRead := 0
82 for maxBytes < 0 || numBytesRead < maxBytes {
83 b, err := f.reader.ReadByte()
84 if err == io.EOF {
85 break
86 }
87 if err != nil {
88 return "", err
89 }
90 if b == '\r' && f.univNewLine {
91 f.skipNextLF = true
92 buf.WriteByte('\n')
93 break
94 } else if b == '\n' {
95 if f.skipNextLF {
96 f.skipNextLF = false
97 continue // Do not increment numBytesRead.
98 } else {
99 buf.WriteByte(b)
100 break
101 }
102 } else {
103 buf.WriteByte(b)
104 }
105 numBytesRead++
106 }
107 return buf.String(), nil
108}

Related snippets