scaffold

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scaffold 实现 appkit new / appkit dev: 生成域仓库与组合仓库骨架(embed 模板 + text/template), 以及本地多仓联调的 go.work 维护。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dev

func Dev(dir, root string, out io.Writer) error

Dev 维护本地多仓联调工作区(appkit dev):

  • 在 dir 下 go work init(已有 go.work 则跳过,幂等);
  • 扫描 root 下含 go.mod 的一级子目录,连同 dir 自身逐个 go work use。

go.work 不提交(骨架 .gitignore 已忽略);发版联动走 require + Renovate。

func Domain

func Domain(o Options, out io.Writer) error

Domain 生成业务域仓库骨架。out 承接进度输出(可为 nil)。

func InstallSchemaTool added in v0.9.3

func InstallSchemaTool(dir string) error

InstallSchemaTool only replaces its own generated files. It does not modify migrations, sqlc configuration, dependencies or any database.

func RenderDomain added in v0.9.0

func RenderDomain(o Options) (map[string][]byte, error)

RenderDomain renders the entire scaffold without touching o.Dir. Migration DDL still comes from the framework library functions, never duplicated SQL. WorkflowRef must already be an explicit commit SHA: resolving provenance is the caller's responsibility and must not turn this renderer into external I/O.

func RenderSystem added in v0.9.0

func RenderSystem(o Options) (map[string][]byte, error)

RenderSystem renders the composition scaffold with no filesystem access.

func SchemaToolFiles added in v0.9.3

func SchemaToolFiles() (map[string][]byte, error)

SchemaToolFiles is shared by new-domain scaffolding and explicit installation in existing repositories. There is one maintained copy of the generator.

func System

func System(o Options, out io.Writer) error

System 生成组合仓库骨架。out 承接进度输出(可为 nil)。

Types

type Options

type Options struct {
	// Name 是域名/系统名,须匹配 ^[a-z][a-z0-9]*$(业务包名 = Postgres schema)。
	Name string
	// Module 是生成仓库的 module path,空则默认 github.com/forgeplex/<name>。
	Module string
	// Dir 是输出目录,空则默认 ./<name>。目录已存在且非空时报错。
	Dir string
	// AppkitVersion 是写进 go.mod 的 appkit 版本(取 cli.Version());
	// "(devel)" 表示源码构建:go.mod 不 require appkit(对不存在版本的
	// require 会让 go 命令去代理拉取而失败),改由 appkit dev 的 go.work 提供。
	AppkitVersion string
	// WorkflowRef 可显式传 appkit 源码的完整 commit;Domain 入口为空时由
	// ruleset 从 AppkitVersion 的来源解析。纯 RenderDomain 必须显式传入,
	// 不会执行外部 git/go 命令;RenderSystem 不消费 workflow ref。
	WorkflowRef string
	// Partitioned 生成「分区域域」形态(仅 domain):一套代码、N 份数据分区,
	// 迁移与查询全部无 schema 前缀,落位由组合根注入的分区映射(分区键 → schema)
	// 经事务级 search_path 路由确定。分区映射的定义放组合根自己的配置文件。
	Partitioned bool
	// Tenant 生成「租户域」形态(仅 domain):行级隔离——业务表带 tenant_id
	// 列并挂 RLS 策略(pgtx.TenantPolicySQL),每次事务把租户身份落成事务级
	// GUC(pgtx.NewTenant)。与 Partitioned 同给即「分区 + 行级」双层:每个
	// 分区一套 schema,分区内再按 tenant_id 分行(pgtx.NewRoutedTenant,
	// 租户 DDL 用无前缀形态)。
	Tenant bool
}

Options 是 appkit new 的输入。

Directories

Path Synopsis
Command schematool derives sqlc's current schema from migrations in a scratch database.
Command schematool derives sqlc's current schema from migrations in a scratch database.

Jump to

Keyboard shortcuts

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