codetemplate

package
v0.0.0-...-e54aff3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

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.

func (*OutputFile) Write

func (of *OutputFile) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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