go: github.com/shurcooL/go/indentwriter Index | Examples | Files

package indentwriter

import "github.com/shurcooL/go/indentwriter"

Package indentwriter implements an io.Writer wrapper that indents every non-empty line with specified number of tabs.

Code:

iw := indentwriter.New(os.Stdout, 1)

io.WriteString(iw, `IndentWriter is simple Go package you can import for the following task.

You take an existing io.Writer, and an integer "indent",
and create this IndentWriter that implements io.Writer too, but it prepends every line with
indent number of tabs.

Note that only non-empty lines get indented.
`)

Output:

	IndentWriter is simple Go package you can import for the following task.

	You take an existing io.Writer, and an integer "indent",
	and create this IndentWriter that implements io.Writer too, but it prepends every line with
	indent number of tabs.

	Note that only non-empty lines get indented.

Index

Examples

Package Files

indentwriter.go

func New Uses

func New(w io.Writer, indent int) io.Writer

New creates a new indent writer that indents non-empty lines with indent number of tabs.

Package indentwriter imports 2 packages (graph) and is imported by 2 packages. Updated 2016-07-21. Refresh now. Tools for package owners.