lexgen

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lexgen generates Go types and client functions from ATProto Lexicon schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(cfg *Config, cat *lexicon.Catalog) (map[string][]byte, error)

Generate produces Go source files from parsed lexicon schemas. Returns a map of file path → file contents.

func TypeName

func TypeName(nsid, defName string) string

TypeName returns the Go type name for a def given an NSID and def name. "app.bsky.feed.post", "main" → "FeedPost" "app.bsky.feed.post", "replyRef" → "FeedPost_ReplyRef" "app.bsky.feed.defs", "postView" → "FeedDefs_PostView"

func WriteFiles

func WriteFiles(files map[string][]byte) error

WriteFiles writes all generated files to disk, creating directories as needed.

Types

type Config

type Config struct {
	Packages          []PackageConfig `json:"packages"`
	SharedTypesDir    string          `json:"sharedTypesDir"`    // output directory for shared types, e.g. "api/lextypes"
	SharedTypesPkg    string          `json:"sharedTypesPkg"`    // Go package name, e.g. "lextypes"
	SharedTypesImport string          `json:"sharedTypesImport"` // full import path, e.g. "github.com/jcalabro/atmos/api/lextypes"
}

Config controls code generation.

type PackageConfig

type PackageConfig struct {
	Prefix  string `json:"prefix"`  // NSID prefix, e.g. "app.bsky"
	Package string `json:"package"` // Go package name, e.g. "bsky"
	OutDir  string `json:"outDir"`  // output directory, e.g. "api/bsky"
	Import  string `json:"import"`  // full import path, e.g. "github.com/jcalabro/atmos/api/bsky"
}

PackageConfig maps an NSID prefix to a Go package.

Jump to

Keyboard shortcuts

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