config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config 负责加载 base-code.yaml 并补齐约定默认值。 设计目标:约定优于配置——layers/包名/idType 等不再配置,仅留必填的工程包与数据库连接。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoFill

type AutoFill struct {
	InsertColumns []string `yaml:"insert-columns"`
	UpdateColumns []string `yaml:"update-columns"`
}

AutoFill 表示自动填充列的约定。

type Config

type Config struct {
	BasePackage   string     `yaml:"base-package"`
	OutputRoot    string     `yaml:"output-root"`
	ResourcesRoot string     `yaml:"resources-root"` // 可选;mapper-xml 输出根,缺省由 OutputRoot 推导
	Author        string     `yaml:"author"`
	UseJakarta    *bool      `yaml:"use-jakarta"` // 指针:区分「未配置」与「配置为 false」
	DateType      string     `yaml:"date-type"`
	Datasource    Datasource `yaml:"datasource"`
	AutoFill      AutoFill   `yaml:"auto-fill"`
}

Config 是生成器的全部配置。 Go 小白知识点:结构体标签 `yaml:"..."` 告诉 yaml 库 YAML 键如何对应字段。

func Load

func Load(path string) (Config, error)

Load 读取并解析配置文件,随后补齐约定默认值。

type Datasource

type Datasource struct {
	Dialect  string `yaml:"dialect"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
}

Datasource 表示数据库连接配置。

Jump to

Keyboard shortcuts

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