package byteutilimport ()// Buffer wrap and extends the bytes.Buffer, add some useful methods// and implements the io.Writer, io.Closer and stdio.Flusher interfacestypeBufferstruct {bytes.Buffer// custom error for testing CloseErr error FlushErr error SyncErr error}// NewBuffer instancefunc () *Buffer { return &Buffer{} }// PrintByte to buffer, ignore error. alias of WriteByte()func ( *Buffer) ( byte) { _ = .WriteByte()}// WriteStr1 quiet write one string to bufferfunc ( *Buffer) ( string) { .writeStringNl(, false) }// WriteStr1Nl quiet write one string and end with newlinefunc ( *Buffer) ( string) { .writeStringNl(, true) }// writeStringNl quiet write one string and end with newlinefunc ( *Buffer) ( string, bool) { _, _ = .Buffer.WriteString()if { _ = .WriteByte('\n') }}// WriteStr quiet write strings to bufferfunc ( *Buffer) ( ...string) { .writeStringsNl(, false)}// WriteStrings to buffer, ignore error.func ( *Buffer) ( []string) { .writeStringsNl(, false)}// WriteStringNl write message to buffer and end with newlinefunc ( *Buffer) ( ...string) { .writeStringsNl(, true)}// writeStringsNl to buffer, ignore error.func ( *Buffer) ( []string, bool) {for , := range { _, _ = .Buffer.WriteString() }if { _ = .WriteByte('\n') }}// WriteAny type value to bufferfunc ( *Buffer) ( ...any) { .writeAnysWithNl(, false)}// Writeln write values to buffer and end with newlinefunc ( *Buffer) ( ...any) { .writeAnysWithNl(, true)}// WriteAnyNl type value to buffer and end with newlinefunc ( *Buffer) ( ...any) { .writeAnysWithNl(, true)}// WriteAnyLn type value to buffer and end with newlinefunc ( *Buffer) ( []any, bool) {for , := range { _, _ = .Buffer.WriteString(fmt.Sprint()) }if { _ = .WriteByte('\n') }}// Writef write message to buffer, ignore error. alias of Printf()func ( *Buffer) ( string, ...any) { _, _ = fmt.Fprintf(, , ...) }// Printf quick write message to buffer, ignore error.func ( *Buffer) ( string, ...any) { _, _ = fmt.Fprintf(, , ...) }// Println quick write message with newline to buffer, will ignore error.func ( *Buffer) ( ...any) { _, _ = fmt.Fprintln(, ...) }// ResetGet buffer string. alias of ResetAndGet()func ( *Buffer) () string {return .ResetAndGet()}// ResetAndGet buffer string.func ( *Buffer) () string { := .String() .Reset()return}// Close bufferfunc ( *Buffer) () error { return .CloseErr }// Flush bufferfunc ( *Buffer) () error { return .FlushErr }// Sync anf flush bufferfunc ( *Buffer) () error { return .SyncErr }
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.