linkname

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: BSD-2-Clause Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoLinkname

type GoLinkname struct {
	Implementation symbol.Name
	Reference      symbol.Name
}

GoLinkname describes a go:linkname compiler directive found in the source code.

GopherJS treats these directives in a way that resembles a symbolic link, where for a single given symbol implementation there may be zero or more symbols referencing it. This is subtly different from the upstream Go implementation, which simply overrides symbol name the linker will use.

func ParseGoLinknames

func ParseGoLinknames(fset *token.FileSet, pkgPath string, file *ast.File) ([]GoLinkname, error)

parseGoLinknames processed comments in a source file and extracts //go:linkname compiler directive from the comments.

The following directive format is supported: //go:linkname <localname> <importpath>.<name> //go:linkname <localname> <importpath>.<type>.<name> //go:linkname <localname> <importpath>.<(*type)>.<name>

GopherJS directive support has the following limitations:

  • External linkname must be specified.
  • The directive must be applied to a package-level function or method (variables are not supported).
  • The local function referenced by the directive must have no body (in other words, it can only "import" an external function implementation into the local scope).

type GoLinknameSet

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

GoLinknameSet is a utility that enables quick lookup of whether a decl is affected by any go:linkname directive in the program.

func (*GoLinknameSet) Add

func (gls *GoLinknameSet) Add(entries []GoLinkname) error

Add more GoLinkname directives into the set.

func (*GoLinknameSet) FindImplementation

func (gls *GoLinknameSet) FindImplementation(sym symbol.Name) (symbol.Name, bool)

FindImplementation returns a symbol name, which provides the implementation for the given symbol. The second value indicates whether the implementation was found.

func (*GoLinknameSet) IsImplementation

func (gls *GoLinknameSet) IsImplementation(sym symbol.Name) bool

IsImplementation returns true if there is a directive referencing this symbol as an implementation.

Jump to

Keyboard shortcuts

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