genx

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comments

type Comments string

Comments 表示Go代码中的注释

func (Comments) String

func (c Comments) String() string

String 将注释转换为Go代码中的注释格式

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 返回给定标识符的限定名称(包名.标识符) 如果标识符在同一包中,则只返回标识符名称

func (*GeneratedFile) Write

func (g *GeneratedFile) Write(p []byte) (n int, err error)

Write 实现 io.Writer 接口,将字节写入内部缓冲区

type GoIdent

type GoIdent struct {
	GoName       string       // 标识符名称
	GoImportPath GoImportPath // 所属包的导入路径
}

GoIdent 表示Go代码中的标识符,包括名称和所属的导入路径

func (GoIdent) String

func (id GoIdent) String() string

String 返回标识符的字符串表示

type GoImportPath

type GoImportPath string

GoImportPath 表示Go代码中的导入路径

func (GoImportPath) Ident

func (p GoImportPath) Ident(s string) GoIdent

Ident 根据名称创建一个在该导入路径下的标识符

func (GoImportPath) String

func (p GoImportPath) String() string

String 返回导入路径的字符串表示

type GoPackageName

type GoPackageName string

GoPackageName 表示Go代码中的包名

Jump to

Keyboard shortcuts

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