Documentation
¶
Index ¶
- type File
- func (g *File) Content() ([]byte, error)
- func (g *File) Filename() string
- func (f *File) Import(importPath string)
- func (g *File) P(v ...any)
- func (f *File) QualifiedGoIdent(ident GoIdent) string
- func (f *File) SetPackageName(importPath string, packageName string)
- func (g *File) Write(p []byte) (n int, err error)
- type GoIdent
- type GoPackageName
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 represents a generated Go file.
func (*File) Import ¶
Import adds a blank import to the file (for side effects). For normal imports, use QualifiedGoIdent instead.
func (*File) QualifiedGoIdent ¶
QualifiedGoIdent returns the qualified Go identifier and manages imports automatically. If the identifier is from the same package, returns just the name. If from a different package, returns packageName.Name and ensures the import is added.
func (*File) SetPackageName ¶
SetPackageName sets a custom package name for the given import path. This allows overriding the default package name derivation.
type GoIdent ¶
type GoIdent struct {
GoImportPath string // Import path, e.g., "encoding/xml"
GoName string // Identifier name, e.g., "Name"
}
GoIdent represents a Go identifier with its import path.
type GoPackageName ¶
type GoPackageName string
GoPackageName represents a package name used in generated code.