natives

package
v0.0.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package natives holds goesm's target-specific replacements for standard library packages whose Go source depends on the gc runtime's memory layout (runtime, internal/reflectlite, ...). Like GopherJS's natives, but kept as Go source: the replacement is parsed in place of the original package's files, so go/types still type-checks every importer against it, and the rest of the standard library compiles from its ordinary Go source.

The set is fixed and owned by goesm. Nothing outside this directory can add replacements, so importing a dependency never extends the compiler.

Functions declared without a body in a replacement, like the standard library's own assembly and linkname declarations, are implemented by the TypeScript runtime (runtime/src/natives.ts, see runtime.NativeName).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeclNames

func DeclNames(d ast.Decl) []string

DeclNames returns the names a top-level declaration declares: "F" for a function, "T.M" for a method of T or *T, and the names of types, variables and constants. Imports declare none.

func Override

func Override(fullName string) bool

Override reports whether the standard library function with the given types.Func.FullName is implemented natively despite having a Go body.

func Packages

func Packages() []string

Packages lists the import paths of the replaced packages.

func Patched

func Patched(importPath string) map[string]bool

Patched returns the names (as DeclNames reports them) of the declarations that the patches of package importPath replace, or nil.

func Sync

func Sync(fullName string) bool

Sync reports whether the standard library function with the given types.Func.FullName is lowered as synchronous despite channel operations.

Types

type File

type File struct {
	Name string // display path, e.g. goesm/natives/runtime/runtime.go
	Src  []byte
}

File is the replacement source of one standard library package.

func Patch

func Patch(importPath, base string) (f File, ok bool)

Patch returns the patch of the standard library file base (a file name) of package importPath. A patch is Go source: its declarations replace the package's declarations of the same names (see Patched) and are added to that file, together with its imports. Patches change a few functions of a package that is otherwise compiled from its original source.

func Replacement

func Replacement(importPath string) (f File, ok bool)

Replacement returns the replacement of the standard library package importPath, or ok == false if goesm compiles it from its original source. A replacement is one file, so the files of the replaced package can be substituted in any order (go/packages parses them concurrently).

Jump to

Keyboard shortcuts

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