gen

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package gen generates project files from platformgo.yaml.

It produces the module wiring, their settings and the environment example. This is what removes manual edits when modules are added or removed: only the domain part stays in project code.

Index

Constants

View Source
const (
	ConfigPath  = "cmd/app/config.gen.go"
	ModulesPath = "cmd/app/modules.gen.go"
	EnvPath     = ".env.example"
	ComposePath = "docker-compose.yml"
)

Paths of generated files, relative to the project root.

View Source
const SettingsModule = "settings"

SettingsModule is the module name whose schema drives the generation.

View Source
const SettingsPath = "internal/settings/settings.gen.go"

SettingsPath is the generated typed access to the business settings. It lives in the project so that domain code reads a setting as a method call rather than a string key.

Variables

This section is empty.

Functions

func Apply

func Apply(dir string, files map[string][]byte) ([]string, error)

Apply writes the generated files that differ from what the project has and returns their paths. Untouched files keep their modification time, so a build that runs generation first does not rebuild everything.

func Changed

func Changed(dir string, files map[string][]byte) ([]string, error)

Changed returns the paths whose content in the project differs from the generated one. An empty list means generation is up to date.

func Files

func Files(dir string, f *spec.File) (map[string][]byte, error)

Files returns everything platformgo generates for the project: the module wiring and, when the settings module is enabled, the typed access to the business settings.

The schema is read from the project directory, so the generated code always matches the file a developer just edited.

func SettingsCode

func SettingsCode(raw []byte) ([]byte, error)

SettingsCode generates the typed access from the schema file contents.

func SettingsEnabled

func SettingsEnabled(f *spec.File) bool

SettingsEnabled reports whether the project enables the settings module.

func SettingsSchemaPath

func SettingsSchemaPath(f *spec.File) string

SettingsSchemaPath is the schema file of the project: settings.yaml unless the module section names another one.

func Wiring

func Wiring(f *spec.File) (map[string][]byte, error)

Wiring returns the generated files: path relative to the project root to content.

Types

This section is empty.

Jump to

Keyboard shortcuts

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