build

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 1

README

Custom Datly projects

project/build.Service owns project initialization and compilation. datly init and datly build are thin CLI adapters; developer tooling may call the same service methods.

Initialize an existing module with datly init -dir /path/to/app. A new module requires an exact Datly pin or an explicit local mapping. Existing files and Go module choices are preserved.

The scaffold contains cmd/datly, internal/datlylink, dql, generated, hooks, resources, and datly.yaml. DQL must be transcribed before building; the build command does not silently regenerate source.

User-owned default imports

internal/datlylink is application-owned selection policy. The application adds or removes one blank import for each component package it wants compiled into the host:

package datlylink

import (
	_ "example.com/app/generated/orders/reader"
	_ "example.com/app/generated/orders/writer"
)

func init() {}

cmd/datly blank-imports only this link package. Generated component packages have an empty init() and never register themselves. The link init is also empty. At runtime GoBootstrap.Packages remains the source-scanning and exposure selection. Bootstrap uses xunsafe.PackageTypes to match scanned holder declarations to linked concrete types and embedded filesystems.

x.Registry is retained for genuinely dynamic types and factories. Linked, generated Go contracts do not populate it.

Generated packages expose embedded assets through the established interface:

EmbedFS() *embed.FS
EmbedNamespace() string

An explicitly custom component holder may expose DatlyHandler(name). Standard generated writers instead use the shared metadata-driven writer and emit no component-specific handler factory. Package SQL remains under its readable namespace and path.

Build

cd /path/to/app
go list -mod=mod -deps ./... >/dev/null
datly build -dir . -o bin/app -tags production
./bin/app run -conf datly.yaml

Build reports component count and the resulting binary digest; it does not count or synthesize type/factory registrations. It inherits the caller's Go environment, including GOWORK, build tags, GOOS, GOARCH, CGO and GOFLAGS. It compiles ./cmd/datly without rewriting the link package, generating a sidecar, or persisting a checksum. A failed build leaves the previous executable intact.

The bootstrap remains source-backed: runtime compilation reads the selected Go, DQL, and resource source files under BaseDir/ModuleDirs. Rebuild after link, tag, dependency, or source changes.

Verification covers a second local model module, linked reader and writer contracts, namespaced embedded SQL, typed custom handlers, native lifecycle methods, add/remove package selection with build tags, real SQLite persistence, and a real TCP executable.

Documentation

Overview

Package build owns custom project initialization and compilation. The application-owned internal/datlylink package selects compiled components. The service is independent of CLI flags and can be reused by developer tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InitRequest

type InitRequest struct {
	Dir, Module string
	// Pins are exact module versions; mutable queries such as latest are rejected.
	Pins map[string]string
	// Local explicitly maps module paths to development directories. Local-only
	// requirements use v0.0.0 placeholders, never asserted published versions.
	Local map[string]string
}

type Request

type Request struct {
	Dir, Output, Tags string
	// Env is the complete Go environment; nil inherits it, including GOWORK.
	Env []string
	// Packages uses Go package patterns. The default is ./... in the project module.
	Packages []string
}

type Result

type Result struct {
	Binary, SHA256 string
	Components     int
}

type Service

type Service struct{}

func (Service) Build

func (Service) Build(ctx context.Context, request Request) (_ *Result, err error)

func (Service) Init

func (Service) Init(ctx context.Context, request InitRequest) error

Jump to

Keyboard shortcuts

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