Help us shape the future of Go! Take the 2026 Go Developer Survey

generate

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package generate proposes catalog entries for the routes of the inventory: parameter values from the configuration, the pristine database or earlier responses, and one entry per template (ok, not-found, json…). Entries written by hand or imported are kept as they are; generated entries are replaced on every run, in the same order every time.

Index

Constants

View Source
const SequencePrefix = "gen-after-"

SequencePrefix marks sequences that generate made.

Variables

This section is empty.

Functions

func FormFields

func FormFields(body []byte) [][2]string

FormFields writes a JSON object as form fields, the way PHP and most frameworks read them back: nested keys in brackets (address[city]), list items by index (tags[0]), true as 1 and false as 0, null as empty.

func IsGenerated

func IsGenerated(r catalog.Request) bool

IsGenerated reports whether an entry came from generate.

func Slug

func Slug(s string) string

Slug turns text into a part of a request ID.

func Storage

func Storage(p *config.Project, id string) string

Storage of a new entry: private unless storage.public names it.

Types

type Options

type Options struct {
	Project    *config.Project
	Inventory  *routes.Inventory
	Exclusions *routes.Exclusions
	Existing   *catalog.Catalog
	Query      Query
	All        bool // also routes that entries written by hand already reach
}

Options of one run.

type Query

type Query func(ctx context.Context, state, sql string) ([]string, error)

Query runs a read-only query of a parameter on a state component.

type Result

type Result struct {
	Catalog   *catalog.Catalog
	Generated int
	Skipped   []Skip
}

Result of a run.

func Run

func Run(ctx context.Context, o Options) (*Result, error)

Run builds the new catalog.

type Skip

type Skip struct {
	Route    string
	Template string
	Reason   string
}

Skip is a request that could not be generated.

Jump to

Keyboard shortcuts

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