package printer

import "github.com/google/gnostic/printer"

Package printer provides support for writing generated code.

Index

Types

type Code

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

Code represents a file of code to be printed.

func (*Code) Indent

func (c *Code) Indent()

Indent adds one level of indentation.

func (*Code) Outdent

func (c *Code) Outdent()

Outdent remvoes one level of indentation.

func (*Code) Print

func (c *Code) Print(args ...interface{})

Print adds a line of code using the current indentation. Accepts printf-style format strings and arguments.

func (*Code) PrintIf

func (c *Code) PrintIf(condition bool, args ...interface{})

PrintIf adds a line of code using the current indentation if a condition is true. Accepts printf-style format strings and arguments.

func (*Code) String

func (c *Code) String() string

String returns the accumulated code as a string.

Source Files

code.go

Version
v0.7.0 (latest)
Published
Aug 25, 2023
Platform
linux/amd64
Imports
1 packages
Last checked
1 week ago

Tools for package owners.