MCPcopy Index your code
hub / github.com/coder/coder / Write

Method Write

coderd/util/xio/limitwriter.go:30–43  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

28}
29
30func (l *LimitWriter) Write(p []byte) (int, error) {
31 if l.N >= l.Limit {
32 return 0, ErrLimitReached
33 }
34
35 // Write 0 bytes if the limit is to be exceeded.
36 if int64(len(p)) > l.Limit-l.N {
37 return 0, ErrLimitReached
38 }
39
40 n, err := l.W.Write(p)
41 l.N += int64(n)
42 return n, err
43}
44
45func (l *LimitWriter) Remaining() int64 {
46 return l.Limit - l.N

Callers 1

TestLimitWriterFunction · 0.95

Calls 1

WriteMethod · 0.65

Tested by 1

TestLimitWriterFunction · 0.76