writer

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const FileNamePrefix = "zz_"
View Source
const FileNameSuffix = ".go"

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeWriter

type FakeWriter struct {
	Files map[string]string
}

FakeWriter is a writer that is useful during tests

func NewFakeWriter

func NewFakeWriter() *FakeWriter

func (*FakeWriter) Clean

func (w *FakeWriter) Clean() error

func (*FakeWriter) WriteFile

func (w *FakeWriter) WriteFile(name string, contents []byte) error

type Writer

type Writer interface {
	// WriteFile writes a named file, adding a prefix and suffix to the name.
	WriteFile(name string, contents []byte) error

	// Clean removes any generated files from previous executions that WriteFile has not touched.
	Clean() error
}

Writer is a mechanism to persist generated Go files

func NewDirWriter

func NewDirWriter(dir string) (Writer, error)

NewDirWriter returns a Writer that writes to the specified directory.

func NewStreamWriter

func NewStreamWriter(dest io.Writer) Writer

NewStreamWriter returns a new Writer that writes to the passed io.Writer. Files written will be prefixed with a comment containing the file name. nil can be passed to discard all writes.

Jump to

Keyboard shortcuts

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