printer

package
Version: v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: BSD-3-Clause Imports: 9 Imported by: 45

Documentation

Overview

Package printer implements printing of AST nodes.

Index

Constants

View Source
const (
	RawFormat uint = 1 << iota // do not use a tabwriter; if set, UseSpaces is ignored
	TabIndent                  // use tabs for indentation independent of UseSpaces
	UseSpaces                  // use spaces instead of tabs for alignment
)

General printing is controlled with these Config.Mode flags.

Variables

This section is empty.

Functions

func Fprint

func Fprint(output io.Writer, fset *token.FileSet, node interface{}) error

Fprint "pretty-prints" an AST node to output. It calls Config.Fprint with default settings.

Types

type Config

type Config struct {
	Mode     uint // default: 0
	Tabwidth int  // default: 8
}

A Config node controls the output of Fprint.

func (*Config) Fprint

func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node interface{}) (int, error)

Fprint "pretty-prints" an AST node to output and returns the number of bytes written and an error (if any) for a given configuration cfg. Position information is interpreted relative to the file set fset. The node type must be *ast.File, or assignment-compatible to ast.Expr, ast.Decl, ast.Spec, or ast.Stmt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL