MCPcopy
hub / github.com/nats-io/nats.go / ReadString

Method ReadString

nats.go:2276–2300  ·  view source on GitHub ↗
(delim byte)

Source from the content-addressed store, hash-verified

2274}
2275
2276func (r *natsReader) ReadString(delim byte) (string, error) {
2277 var s string
2278build_string:
2279 // First look if we have something in the buffer
2280 if r.off >= 0 {
2281 i := bytes.IndexByte(r.buf[r.off:r.n], delim)
2282 if i >= 0 {
2283 end := r.off + i + 1
2284 s += string(r.buf[r.off:end])
2285 r.off = end
2286 if r.off >= r.n {
2287 r.off = -1
2288 }
2289 return s, nil
2290 }
2291 // We did not find the delim, so will have to read more.
2292 s += string(r.buf[r.off:r.n])
2293 r.off = -1
2294 }
2295 if _, err := r.Read(); err != nil {
2296 return s, err
2297 }
2298 r.off = 0
2299 goto build_string
2300}
2301
2302// createConn will connect to the server and wrap the appropriate
2303// bufio structures. It will do the right thing when an existing

Callers 8

startHeaderCatcherFunction · 0.80
readProtoMethod · 0.80
TestMoreErrOnConnectFunction · 0.80
TestFlushReleaseOnCloseFunction · 0.80
TestMaxPendingOutFunction · 0.80
TestErrInReadLoopFunction · 0.80
TestErrStaleConnectionFunction · 0.80

Calls 1

ReadMethod · 0.95

Tested by 7

startHeaderCatcherFunction · 0.64
TestMoreErrOnConnectFunction · 0.64
TestFlushReleaseOnCloseFunction · 0.64
TestMaxPendingOutFunction · 0.64
TestErrInReadLoopFunction · 0.64
TestErrStaleConnectionFunction · 0.64