unionnames

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 4 Imported by: ? 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 unionnames allocates Go members for generated union carriers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(union *expr.Union) map[string]Member

Resolve allocates members keyed by original branch name. Ordinary names stay unchanged. Sanitized collisions receive numeric suffixes in logical-name order, independent of branch order. Storage allocation reserves every method and every original field candidate before adding suffixes, so a renamed field cannot steal another branch's name. JSON-only and form carriers share names.

Types

type BranchSymbols

type BranchSymbols struct {
	// KindConst identifies this branch in the union's discriminator type.
	KindConst string
	// Constructor builds a union value with this branch selected.
	Constructor string
}

BranchSymbols identifies a branch's declarations in its enclosing package.

func BranchDeclarations

func BranchDeclarations(primary, method string) BranchSymbols

BranchDeclarations derives a branch's package identifiers from an allocated union name and the accessor suffix returned by Resolve. Emitters that already hold resolved member data use this same policy as the full family inventory.

type Member

type Member struct {
	// Method is the suffix of the constructor, As and Set methods and kind constant.
	Method string
	// Field is the storage field, distinct from every generated method and sibling.
	Field string
}

Member separates a branch's public accessor suffix from its storage field.

type PackageSymbols

type PackageSymbols struct {
	// KindName is the named type of the union discriminator constants.
	KindName string
	// Branches maps authored branch names to their package declarations.
	Branches map[string]BranchSymbols
	// Names lists every companion declaration, excluding the primary union type.
	// Order follows the authored branches; names use the resolved member identity.
	Names []string
}

PackageSymbols identifies the package declarations accompanying one union. Its primary type is named by the caller's owning NameScope.

func PackageDeclarations

func PackageDeclarations(union *expr.Union, primary string) PackageSymbols

PackageDeclarations derives a union's complete common package declaration inventory from its allocated primary name. Allocation, emitters and value construction consume this same policy, including sanitized member names. Owner-specific declarations, such as native Any aliases, are added by the domain that emits them before it allocates the complete family.

Jump to

Keyboard shortcuts

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