indentwriter

package
v0.0.0-...-5fe729b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 2 Imported by: 7

Documentation

Overview

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

Example
package main

import (
	"io"
	"os"

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

func main() {
	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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL