importer

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package importer provides a common interface used to import Risor modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Importer

type Importer interface {
	// Import a module by name
	Import(ctx context.Context, name string) (*object.Module, error)
}

Importer is an interface used to import Risor code modules

type LocalImporter

type LocalImporter struct {
	// contains filtered or unexported fields
}

func NewLocalImporter

func NewLocalImporter(opts LocalImporterOptions) *LocalImporter

NewLocalImporter returns an Importer that can read Risor code modules from the local filesystem. Internally, loaded code is cached in memory. However, a new Module is created for each Import call. If the caller wants to reuse the same Module, it should be cached by the caller. It is safe to reuse the same local importer across multiple VMs and evaluations, because the cached code is immutable.

func (*LocalImporter) Import

func (i *LocalImporter) Import(ctx context.Context, name string) (*object.Module, error)

type LocalImporterOptions

type LocalImporterOptions struct {
	// Global names that should be available when the module is compiled.
	GlobalNames []string

	// The directories to search for Risor modules.
	SourceDirs []string

	// Optional list of file extensions to try when locating a Risor module.
	Extensions []string
}

LocalImporterOptions configure an Importer that can read from the local filesystem.

Jump to

Keyboard shortcuts

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