Documentation
¶
Overview ¶
Multiwriter that does not error on a single error
Index ¶
- Constants
- Variables
- func Assert(condition bool, message string, args ...any)
- func Copy(src string, dst string) error
- func CopyFromReader(src io.Reader, dst string) error
- func CreateFile(rc io.ReadCloser, length int64, path string) (resultPath string, err error)
- func CreateTempFile() (path string, file *os.File, err error)
- func Ignore2[T, V any](a T, b V) T
- func MultiWriter(writers ...io.Writer) io.Writer
- func RenameSafe(oldpath string, newpath string) error
- func StripAnsi(s string) string
- func StripAnsiBytes(b []byte) []byte
- func TempDirectory() string
- func Unzip(path string) error
- func ValidPath(path string) bool
- type StreamBuffer
- type SwapSlice
Constants ¶
const TmpDirSubDirectory = "__updater__001020"
Variables ¶
var ErrTooLarge = errors.New("bytes.Buffer: too large")
ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.
Functions ¶
func CreateFile ¶
func RenameSafe ¶
func StripAnsiBytes ¶ added in v0.1.3
func TempDirectory ¶ added in v0.4.0
func TempDirectory() string
Types ¶
type StreamBuffer ¶ added in v0.0.10
A StreamBuffer is a variable-sized buffer of bytes with StreamBuffer.Read and StreamBuffer.Write methods. The zero value for StreamBuffer is an empty buffer ready to use.
func (*StreamBuffer) Bytes ¶ added in v0.2.0
func (b *StreamBuffer) Bytes() []byte
TODO should i return a copy of the bytes? is this thread safe (i dont think so)? but copying the data can be slow because i plan to call this functions very often
func (*StreamBuffer) Len ¶ added in v0.0.10
func (b *StreamBuffer) Len() int
Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).
func (*StreamBuffer) Read ¶ added in v0.0.10
func (b *StreamBuffer) Read(p []byte) (n int, err error)
Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil.
func (*StreamBuffer) Reset ¶ added in v0.0.10
func (b *StreamBuffer) Reset()
Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as [StreamBuffer.Truncate](0).
func (*StreamBuffer) Write ¶ added in v0.0.10
func (b *StreamBuffer) Write(p []byte) (n int, err error)
Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.