types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types maintains the catalog of data generator types known to mockagen. It combines Mockaroo-compatible type names with go-faker struct tags, database SQL affinities, parameter constraints, and naming hints used by schema inference.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FakerTag

func FakerTag(name string) string

FakerTag returns the struct tag string for type name, or an empty string if the type is unknown. Matches historical mapToFaker lookup behavior.

func FakerTags

func FakerTags() map[string]string

FakerTags returns a copy of the mapping from Mockaroo type names to faker struct tags. Provided for compatibility with legacy test helpers.

Types

type SQLAffinity

type SQLAffinity string

SQLAffinity classifies generator types into coarse database affinities. Used by schema inference to select candidate types for a given SQL column type without hardcoding parallel lookup tables.

const (
	AffinityText   SQLAffinity = "text"
	AffinityInt    SQLAffinity = "int"
	AffinityFloat  SQLAffinity = "float"
	AffinityBool   SQLAffinity = "bool"
	AffinityTime   SQLAffinity = "time"
	AffinityBinary SQLAffinity = "binary"
)

type Type

type Type struct {
	Name           string
	FakerTag       string
	Kind           string
	Affinity       SQLAffinity
	RequiresValues bool
	RequiresMin    bool
	RequiresMax    bool
	RequiresFormat bool
	NameHints      []string
}

Type represents a generator type registered in mockagen's catalog. It bundles the faker struct tag with metadata, affinity, parameter requirements, and inference name hints.

func All

func All() []Type

All returns a slice of all registered generator types in the catalog, sorted alphabetically by Name.

func Candidates

func Candidates(affinity SQLAffinity) []Type

Candidates returns all registered generator types matching the requested SQL affinity, sorted alphabetically by Name for stable output.

func Lookup

func Lookup(name string) (Type, bool)

Lookup reports whether a generator type is registered in the catalog and returns its specification.

Jump to

Keyboard shortcuts

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