Documentation ¶
Overview ¶
Package codetemplate provides a small wrapper type that makes it more convenient to generate correctly formatted Go source files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OutputFile ¶
type OutputFile struct { Filename string // contains filtered or unexported fields }
OutputFile buffers file contents, either written directly via its io.Writer interface or via text/template expansion, and writes the data to the chosen destination file. The data is initially written to a temporary file and renamed into place to replace the destination file, resulting in an atomic replacement.
func New ¶
func New(filename string) *OutputFile
func (*OutputFile) Close ¶
func (of *OutputFile) Close() error
Close creates a temporary file, writes the buffered file contents to it, and renames it into place.
func (*OutputFile) ExpandTemplate ¶
func (of *OutputFile) ExpandTemplate(text string, data interface{}, funcs template.FuncMap) error
ExpandTemplate parses a text/template and executes it with the provided input data.
Click to show internal directories.
Click to hide internal directories.