Help us shape the future of Go! Take the 2026 Go Developer Survey

indent

package module
v0.0.0-...-8fe1000 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: GPL-2.0, GPL-2.0-or-later Imports: 3 Imported by: 2

README

Package indent provides a wrapper to a Writer interface that inserts a leveled preface to each line.


© 2015-2018 Platina Systems, Inc. All rights reserved. Use of this source code is governed by this BSD-style LICENSE.

Documentation

Overview

Package indent provides a wrapper to a Writer interface that inserts a leveled preface to the beginning of each line.

Example
w := New(os.Stdout, "\t")
fmt.Fprintln(w, "level 0")
Increase(w)
fmt.Fprintln(w, "level 1")
Increase(w)
fmt.Fprintln(w, "level 2")
Increase(w)
fmt.Fprintln(w, "level 3")
Decrease(w)
fmt.Fprintln(w, "back to level 2")
Decrease(w)
fmt.Fprintln(w, "back to level 1")
Increase(w)
fmt.Fprintln(w, "another level 2")
Decrease(w)
Decrease(w)
fmt.Fprintln(w, "back level 0")
Decrease(w)
fmt.Fprintln(w, "caught -1")
Increase(w)
fmt.Fprintln(w, "level 1")
Output:
level 0
	level 1
		level 2
			level 3
		back to level 2
	back to level 1
		another level 2
back level 0
caught -1
	level 1

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrease

func Decrease(w io.Writer)

Decrease the preface repetition level for the given or embedded indentor. This will not go below zero.

func Increase

func Increase(w io.Writer)

Increase the preface repetition level for the given or embedded indentor.

func New

func New(w io.Writer, preface string) io.Writer

New returns an indentor initialized to level zero, meaning, no preface is inserted on each line until this is Increase[d].

Types

This section is empty.

Jump to

Keyboard shortcuts

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