Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LinesPrinter ¶
type LinesPrinter struct {
// contains filtered or unexported fields
}
LinesPrinter break string into fixed length lines. caller must call Close to flush remaining bytes and an extra ending sep after use.
func NewLinesPrinter ¶
func NewLinesPrinter(w io.Writer, lineLen int, sep []byte) *LinesPrinter
NewLinesPrinter new a printer with line length limit and separator
Example ¶
package main import ( "encoding/base64" "os" "github.com/gonejack/linesprinter" ) func main() { p := linesprinter.NewLinesPrinter(os.Stdout, 76, []byte("\r\n")) defer p.Close() w := base64.NewEncoder(base64.StdEncoding, p) defer w.Close() t := "this is some random string this is some random string this is some random string" w.Write([]byte(t)) // stdout: // dGhpcyBpcyBzb21lIHJhbmRvbSBzdHJpbmcgdGhpcyBpcyBzb21lIHJhbmRvbSBzdHJpbmcgdGhp // cyBpcyBzb21lIHJhbmRvbSBzdHJpbmc= }
Output:
func NewLinesPrinterN ¶
NewLinesPrinterN new a printer with control of how many lines could stay in memory thus users can control internal buffer size.
func (*LinesPrinter) Close ¶
func (x *LinesPrinter) Close() (e error)
Close the caller must call Close to flush any partially line, and ending sep.
Click to show internal directories.
Click to hide internal directories.