printer

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Printer

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

Printer prints AST nodes

func New

func New(fs *token.FileSet, typeSpecs []*ast.TypeSpec, typesPrefix string) *Printer

New returns Printer If srcPackageName is not empty Printer assumes that printed node goes to the package different from the srcPackageName and all references to the types listed in typeSpecs should be prepended with the source package name selector

func (*Printer) Print

func (p *Printer) Print(node ast.Node) (string, error)

Print prints AST node as is

func (*Printer) PrintType

func (p *Printer) PrintType(node ast.Node) (string, error)

PrintType prints node that represents a type, i.e. type of a function argument or a or struct field If node references one of the types listed in p.types and srcPackageName is not empty it adds source package selector to the type identifier PrintType returns error if the srcPackageName is not empty and the printed type is unexported.

Jump to

Keyboard shortcuts

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