Documentation
¶
Index ¶
- Constants
- Variables
- func Encode(data *[]byte, chars []rune) error
- func IndicesOf(slice []byte, sep []byte) []int
- type MultiWriter
- func (w *MultiWriter) Print(args ...any) error
- func (w *MultiWriter) Printf(format string, args ...any) error
- func (w *MultiWriter) Println(args ...any) error
- func (mw *MultiWriter) Write(data []byte) (int, error)
- func (w *MultiWriter) WriteBytes(data []byte) error
- func (w *MultiWriter) WriteMany(datas ...[]byte) error
- func (w *MultiWriter) WriteNewline() error
- func (w *MultiWriter) WriteString(str string) error
- func (w MultiWriter) Written() int
Constants ¶
const NewlineLen int = 1
Variables ¶
var Newline []byte
var SD bytesT
SD is the namespace for SD-like functions.
Functions ¶
Types ¶
type MultiWriter ¶
type MultiWriter struct {
// contains filtered or unexported fields
}
MultiWriter is a writer that writes multiple data to the underlying io.Writer. Useful for writing many bytes at once.
func New ¶
func New(w io.Writer) (*MultiWriter, error)
New creates a new MultiWriter for the given io.Writer.
Parameters:
- w: The underlying io.Writer.
Returns:
- *MultiWriter: The new MultiWriter.
- error: An error if w is nil.
func (*MultiWriter) Print ¶
func (w *MultiWriter) Print(args ...any) error
Print writes the given arguments to the underlying io.Writer.
Parameters:
- args: The arguments to write.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (*MultiWriter) Printf ¶
func (w *MultiWriter) Printf(format string, args ...any) error
Printf formats the given arguments according to the given format string and writes the result to the underlying io.Writer.
Parameters:
- format: The format string.
- args: The arguments to format.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (*MultiWriter) Println ¶
func (w *MultiWriter) Println(args ...any) error
Println writes the given arguments to the underlying io.Writer, followed by a newline.
Parameters:
- args: The arguments to write.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (*MultiWriter) Write ¶
func (mw *MultiWriter) Write(data []byte) (int, error)
Write implements io.Writer.
func (*MultiWriter) WriteBytes ¶
func (w *MultiWriter) WriteBytes(data []byte) error
WriteBytes writes the data to the underlying io.Writer. This does the same thing as Write, but does not return the number of bytes written.
Parameters:
- data: The data to write.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (*MultiWriter) WriteMany ¶
func (w *MultiWriter) WriteMany(datas ...[]byte) error
WriteMany writes many data to the underlying io.Writer. This is a convenience function that acts like WriteBytes for many data in a more efficient way.
Parameters:
- datas: The datas to write.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (*MultiWriter) WriteNewline ¶
func (w *MultiWriter) WriteNewline() error
WriteNewline writes a newline character to the underlying io.Writer.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (*MultiWriter) WriteString ¶
func (w *MultiWriter) WriteString(str string) error
WriteString writes the given string to the underlying io.Writer.
Parameters:
- str: The string to write.
Returns:
- error: An error if writing failed.
Errors:
- io.ErrShortWrite: If the data is not fully written.
- any other error returned by the underlying io.Writer.
func (MultiWriter) Written ¶
func (w MultiWriter) Written() int
Written returns the total number of bytes written.
Returns:
- int: The total number of bytes written.