MCPcopy
hub / github.com/DarthSim/overmind / ScanLines

Function ScanLines

utils/utils.go:87–116  ·  view source on GitHub ↗

ScanLines reads line by line from reader. Doesn't throw "token too long" error like bufio.Scanner

(r io.Reader, callback func([]byte) bool)

Source from the content-addressed store, hash-verified

85
86// ScanLines reads line by line from reader. Doesn't throw "token too long" error like bufio.Scanner
87func ScanLines(r io.Reader, callback func([]byte) bool) error {
88 var (
89 err error
90 line []byte
91 isPrefix bool
92 )
93
94 reader := bufio.NewReader(r)
95 buf := new(bytes.Buffer)
96
97 for {
98 line, isPrefix, err = reader.ReadLine()
99 if err != nil {
100 break
101 }
102
103 buf.Write(line)
104
105 if !isPrefix {
106 if !callback(buf.Bytes()) {
107 return nil
108 }
109 buf.Reset()
110 }
111 }
112 if err != io.EOF && err != io.ErrClosedPipe {
113 return err
114 }
115 return nil
116}
117
118func FprintRpad(w io.Writer, str string, l int) {
119 fmt.Fprint(w, str)

Callers 5

RunMethod · 0.92
RunMethod · 0.92
parseProcfileFunction · 0.92
scanOuputMethod · 0.92
handleConnectionMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…