refactor(executor/local): remove unused buffer struct
Some checks failed
build / build (push) Failing after 30s
build / trigger-build-image (push) Has been skipped
submodules sync / sync (push) Successful in 32s

This commit is contained in:
张泊明518370910136 2024-11-28 13:56:09 -05:00
parent 9ac80d7f3d
commit 11c2f65ea2
GPG Key ID: D47306D7062CDA9D

View File

@ -1,35 +0,0 @@
package local
import (
"bytes"
"errors"
)
// LimitedBuffer wraps a bytes.Buffer and limits its size.
type LimitedBuffer struct {
buf *bytes.Buffer
maxSize int
}
// Write writes data to the buffer and checks the size limit.
func (lb *LimitedBuffer) Write(p []byte) (n int, err error) {
if lb.buf.Len()+len(p) > lb.maxSize {
// Truncate to fit within the limit
allowed := lb.maxSize - lb.buf.Len()
if allowed > 0 {
n, _ = lb.buf.Write(p[:allowed])
}
return n, errors.New("buffer size limit exceeded")
}
return lb.buf.Write(p)
}
// Bytes returns the buffer's content.
func (lb *LimitedBuffer) Bytes() []byte {
return lb.buf.Bytes()
}
// String returns the buffer's content as a string.
func (lb *LimitedBuffer) String() string {
return lb.buf.String()
}