tinygo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package tinygo extracts a bundled TinyGo toolchain to a local cache directory and compiles BPF Go source with it. The bumble flavor feeds it the embedded release tree (see embed_bumble.go); tests feed it any fs.FS carrying a bin/tinygo entry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileWith

func CompileWith(bin, source string, extraEnv ...string) ([]byte, error)

CompileWith compiles BPF Go source with the given tinygo binary, mirroring hive.CompileC for C source.

Types

type Toolchain

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

Toolchain is a TinyGo release tree plus the cache directory it is extracted to on first use.

func New

func New(fsys fs.FS, cacheDir string) *Toolchain

New returns a Toolchain rooted at fsys (the directory containing bin/tinygo) that extracts into cacheDir.

func (*Toolchain) Compile

func (t *Toolchain) Compile(source string) ([]byte, error)

Compile extracts the toolchain if needed and compiles BPF Go source with it. TINYGOROOT points at the extracted tree so the relocated binary finds its runtime.

func (*Toolchain) Extract

func (t *Toolchain) Extract() (string, error)

Extract unpacks the toolchain into the cache directory unless a previous run already did, and returns the tinygo binary path. Extraction goes through a temp directory renamed into place, so a crashed run never leaves a half-populated cache behind.

Jump to

Keyboard shortcuts

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