printer

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package printer implements auto-indenting printer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type P

type P struct {
	// contains filtered or unexported fields
}

func (*P) Bytes

func (p *P) Bytes() []byte

Bytes returns the bytes written by Printf. It is valid up to the next call to Printf or Reset.

func (*P) Printf

func (p *P) Printf(s string, args ...interface{})

Printf format-writes to p's buffer. The formatting is similar to the fmt package, and the written content can be retrieved with Bytes. Printf is line-oriented: each call should correspond to a new line in the output. Printf automatically inserts a newline at the end of each call.

Printf automatically keeps track of curly-braces and indents lines accordingly. The indentation is not "gofmt-correct" but should print code in "curly brace languages" well enough that callers don't need to keep track of indentation level. Printf ignores leading and trailing whitespaces in s; callers can use them for visual aid without interfering with automatic indentation.

func (*P) Reset

func (p *P) Reset()

Reset resets p but retains the underlying storage for use by future Printfs.

func (*P) String

func (p *P) String() string

func (*P) Writer

func (p *P) Writer() io.Writer

Writer returns a writer that writes to p's underlying buffer without performing indentation.

Jump to

Keyboard shortcuts

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