gen

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenGrpc   = "grpc"
	GenDB     = "database"
	GenDoc    = "doc"
	GenRouter = "router"
)

Variables

This section is empty.

Functions

func AppendByteFile

func AppendByteFile(filePath string, data []byte) error

func AppendStringFile

func AppendStringFile(filePath string, data string) error

func CarGen

func CarGen(name, dbName, grpcPath, grpcPkgName, distPath, distPkg string)

func CreateApiRouter

func CreateApiRouter(genPath string)

CreateApiRouter 生成api路由

func CreateFilePath

func CreateFilePath(path string) error

func GormGen

func GormGen(path, dsn, name string, tables []string)

func IsExist

func IsExist(f string) bool

func IsFile

func IsFile(f string) bool

func ModelToProtobuf

func ModelToProtobuf(path, protoPkg, goPkg, modelPath, modelName string)

func ReadAll

func ReadAll(filePth string) ([]byte, error)

func WriteByteFile

func WriteByteFile(filePath string, data []byte) error

func WriteStringFile

func WriteStringFile(filePath string, data string) error

Types

type Config

type Config struct {
	Gen     string //生成类型
	Path    string //基础项目路径
	Name    string //服务名
	Des     string //描述
	Version string //版本
	DbDsn   string //数据库Dsn
	Tables  string //数据表 ,隔开
	DbName  string //库别名 避免名称过长或者库名差异
	Out     string //输出目录
}

func (Config) Build

func (c Config) Build()

type FileInfo

type FileInfo struct {
	Name   string
	Buffer bytes.Buffer
}

type Generator

type Generator struct {
	Model    string
	PkgPath  string
	PkgName  string
	DistPath string
	DistPkg  string
	DbName   string

	ServiceFields []ServiceField
	MethodImports []string
	ServiceFiles  []ServiceFileInfo
	// contains filtered or unexported fields
}

func (*Generator) Run

func (g *Generator) Run() error

type ServiceField

type ServiceField struct {
	Import string
	Field  string
}

type ServiceFileInfo

type ServiceFileInfo struct {
	FileInfo
}

ServiceFileInfo 文件内容

Jump to

Keyboard shortcuts

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