writer

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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