gen

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 20 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 gen renders the code of a project from embedded templates. Most of the logic lives in the view types, which precompute code fragments so the templates stay readable.

Index

Constants

View Source
const (
	Header     = "// Code generated by codebuild. DO NOT EDIT."
	YAMLHeader = "# Code generated by codebuild. DO NOT EDIT."
)
View Source
const (
	GRPCModule      = "google.golang.org/grpc"
	GRPCVersion     = "v1.84.0"
	ProtobufModule  = "google.golang.org/protobuf"
	ProtobufVersion = "v1.36.12"
	GatewayDir      = "gateway"
	SharedDir       = "databases/shared"
)

Variables

This section is empty.

Functions

func FormatGo

func FormatGo(src []byte) ([]byte, error)

func FormatGoModule

func FormatGoModule(src []byte, module string) ([]byte, error)

Templates import everything they might need. FormatGoModule drops the imports a file ends up not using, groups the rest the way goimports does and runs gofmt.

Types

type File

type File struct {
	Path          string
	Content       []byte
	Owner         Owner
	Domain        string
	ServiceType   string
	Receiver      string
	ServiceMethod string
	Module        string
}

func Generate

func Generate(opts Options) ([]File, error)

type Module

type Module struct {
	Dir      string
	Path     string
	Requires [][2]string
	Locals   []string
}

type Options

type Options struct {
	Module        string
	GoVersion     string
	Caps          goversion.Capabilities
	Dialect       dialect.Dialect
	Model         *schema.Model
	Pagination    Pagination
	ManualWiring  []string
	HasMigrations bool
}

type Owner

type Owner string
const (
	OwnerGenerated Owner = "generated"
	OwnerUser      Owner = "user"
)

type Pagination

type Pagination struct {
	DefaultLimit int `json:"defaultLimit"`
	MaxLimit     int `json:"maxLimit"`
}

type Workspace

type Workspace struct {
	Files   []File
	Modules []Module
}

func GenerateWorkspace

func GenerateWorkspace(opts WorkspaceOptions) (*Workspace, error)

type WorkspaceOptions

type WorkspaceOptions struct {
	Module     string
	GoVersion  string
	Caps       goversion.Capabilities
	Dialect    dialect.Dialect
	Model      *schema.Model
	Pagination Pagination
	Contracts  *contract.Set
	Migrations map[string]bool
}

Jump to

Keyboard shortcuts

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