Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneratedFile ¶
type GeneratedFile struct {
ImportRewriteFunc func(GoImportPath) GoImportPath // 导入路径重写函数
// contains filtered or unexported fields
}
GeneratedFile 表示一个正在生成的Go源文件
func NewGeneratedFile ¶
func NewGeneratedFile(filename string, goImportPath GoImportPath) *GeneratedFile
NewGeneratedFile 创建一个新的生成文件实例
func (*GeneratedFile) Content ¶
func (g *GeneratedFile) Content() ([]byte, error)
Content 获取生成的文件内容,如果文件是Go源码则自动处理导入声明
func (*GeneratedFile) Import ¶
func (g *GeneratedFile) Import(importPath GoImportPath)
Import 添加一个手动导入的包路径
func (*GeneratedFile) P ¶
func (g *GeneratedFile) P(v ...any)
P 将参数打印到缓冲区,每行结束添加换行符 特殊处理 GoIdent 类型,将其转换为适当的限定名称
func (*GeneratedFile) QualifiedGoIdent ¶
func (g *GeneratedFile) QualifiedGoIdent(ident GoIdent) string
QualifiedGoIdent 返回给定标识符的限定名称(包名.标识符) 如果标识符在同一包中,则只返回标识符名称
type GoIdent ¶
type GoIdent struct {
GoName string // 标识符名称
GoImportPath GoImportPath // 所属包的导入路径
}
GoIdent 表示Go代码中的标识符,包括名称和所属的导入路径
Click to show internal directories.
Click to hide internal directories.