embedpkg

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Overview

Package embedpkg loads imports and files using the embed Go package.

More specifically, the GX source files of a GX package are embedded into a matching Go package. This process is done by google3/third_party/gxlang/gx/golang/packager/packager using the embed package from the Go standard library. These GX-Go packages are then statically linked into the binary.

At runtime, all GX packages are registered at startup using this package. When a GX package is imported, the embedded source code is compiled into the GX intermediate representation and returned to the caller.

This intermediate representation can be compiled for a specific device by the GX interpreter or can be used to generate bindings for a given language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() importers.Importer

New returns a new importer.

func NewBuilder

func NewBuilder(stdlibImpl *impl.Stdlib) *builder.Builder

NewBuilder returns a builder loading GX files from the files embedded in the binary.

func RegisterPackage

func RegisterPackage(path string, buildFunc BuildFunc)

RegisterPackage registers the build function of a package given its path.

Types

type BuildFunc

type BuildFunc func(*builder.Builder) (builder.Package, error)

BuildFunc defines the function that a Go library packaging GX files needs to implement.

type Importer

type Importer struct{}

Importer maps GX package path to a Build function defined by the Go library packaging the GX files.

func (*Importer) Import

func (imp *Importer) Import(bld *builder.Builder, path string) (builder.Package, error)

Import a package given its path.

func (*Importer) Support

func (imp *Importer) Support(path string) bool

Support returns true if path has been registered.

Jump to

Keyboard shortcuts

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