discover

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package discover finds tygor export functions by signature.

It scans a Go package for functions with these signatures:

  • func() *tygor.App
  • func() *tygorgen.Generator

No directives or annotations needed — the signature is the marker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFunc

type ConfigFunc struct {
	Name string         // function name
	Pos  token.Position // source location
}

ConfigFunc represents a discovered config function. Signature: func(*tygorgen.Generator) *tygorgen.Generator

type Export

type Export struct {
	Name string         // function name
	Type ExportType     // return type
	Pos  token.Position // source location
}

Export represents a discovered export function.

func SelectExport

func SelectExport(exports []Export, name string) (*Export, error)

SelectExport picks the export to use based on found exports and optional name.

If name is empty:

  • Returns the export if exactly one found
  • Returns error if zero or multiple found

If name is specified:

  • Returns the export with that name
  • Returns error if not found

type ExportType

type ExportType int

ExportType represents the return type of an export function.

const (
	ExportTypeApp       ExportType = iota // func() *tygor.App
	ExportTypeGenerator                   // func() *tygorgen.Generator
)

func (ExportType) String

func (t ExportType) String() string

type Result

type Result struct {
	Exports     []Export
	ConfigFunc  *ConfigFunc // optional config function
	PackagePath string
	ModulePath  string
	ModuleDir   string // directory containing go.mod
	Dir         string // directory containing the package
}

Result contains discovered exports and package info.

func Find

func Find(pattern string) (*Result, error)

Find scans a Go package for export functions.

The pattern follows go command semantics:

  • "." for current directory
  • Import path like "github.com/foo/bar"
  • Absolute or relative directory path

func FindDir

func FindDir(pattern, dir string) (*Result, error)

FindDir is like Find but allows specifying a working directory.

Jump to

Keyboard shortcuts

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