MCPcopy Create free account
hub / github.com/JordanCoin/codemap / Write

Method Write

cmd/hooks.go:69–88  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

67}
68
69func (w *cappedStringWriter) Write(p []byte) (int, error) {
70 if w.maxBytes <= 0 {
71 w.truncated = true
72 return len(p), nil
73 }
74
75 remaining := w.maxBytes - w.buf.Len()
76 if remaining <= 0 {
77 w.truncated = true
78 return len(p), nil
79 }
80 if len(p) <= remaining {
81 _, _ = w.buf.Write(p)
82 return len(p), nil
83 }
84
85 _, _ = w.buf.Write(p[:remaining])
86 w.truncated = true
87 return len(p), nil
88}
89
90func (w *cappedStringWriter) String() string {
91 return w.buf.String()

Callers 3

appendMetricsFunction · 0.80
hashFromStringsFunction · 0.80
TestCappedStringWriterFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestCappedStringWriterFunction · 0.64