Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package model 定义扫表得到的元数据结构,对应 Java 版 ColumnMetadata/FieldMetadata/TableMetadata。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnMetadata

type ColumnMetadata struct {
	ColumnName    string
	ColumnType    string
	ColumnComment string
	IsPrimaryKey  bool
}

ColumnMetadata 是扫表直接得到的列信息(数据库视角)。

type FieldMetadata

type FieldMetadata struct {
	JavaType     string
	JdbcType     string
	Name         string // 小驼峰字段名
	TableField   string // 原始列名
	Comment      string
	AutoFill     string // "" / insert / update / insertUpdate
	IsPrimaryKey bool
}

FieldMetadata 是经类型映射 + 命名转换后的字段(Java 视角)。 字段首字母大写 = 导出,模板(text/template)只能访问导出字段。

func FindSinglePrimaryKey

func FindSinglePrimaryKey(fields []FieldMetadata, tableName string) (FieldMetadata, error)

FindSinglePrimaryKey 定位唯一主键;无主键或复合主键时快速失败。 Go 小白知识点:Go 没有异常,错误通过返回值 error 显式传播(对应 Java 的 throw IllegalStateException)。

type TableMetadata

type TableMetadata struct {
	TableName    string
	TableComment string
	Columns      []ColumnMetadata
}

TableMetadata 是一张表的完整元数据。

Jump to

Keyboard shortcuts

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