codegen

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File is a code generation file.

func NewFile

func NewFile(cfg FileConfig) *File

NewFile creates a new code generation file.

func (*File) Content

func (f *File) Content() (_ []byte, err error)

Content returns the formatted Go source of the file.

func (*File) Import

func (f *File) Import(path string) string

Import includes the provided import path in the file's imports and returns a package identifier.

func (*File) P

func (f *File) P(args ...interface{})

P prints args to the generated file.

func (*File) Write

func (f *File) Write(p []byte) (int, error)

Write implements io.Writer.

type FileConfig

type FileConfig struct {
	// Filename of the generated file.
	Filename string
	// Package of the generated file.
	Package string
	// GeneratedBy line to print to the generated file.
	GeneratedBy string
	// BuildTag is an optional build tag to include in the file header.
	BuildTag string
}

FileConfig configures a code generation file.

type Imports

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

Imports manages imports for a generated file.

func NewImports

func NewImports() *Imports

NewImports creates a new imports set.

func (*Imports) Bytes

func (i *Imports) Bytes() []byte

Bytes returns the generated code bytes for the imports.

func (*Imports) Import

func (i *Imports) Import(path string) string

Import includes the provided identifier in the imports returns a package identifier.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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