dlutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 14 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

View Source
const Supported = true

Whether this build can load shared libraries

Variables

View Source
var ErrNoCallback = errors.New("no C callback support for " + runtime.GOOS + "/" + runtime.GOARCH)

Error for a build that has no trampoline through which C can call a Go function

View Source
var ErrNotFound = errors.New("library not found")

Error for a library that no name, path or search turned up

View Source
var ErrUnsupported = errors.New("no dynamic library loader for " + runtime.GOOS + "/" + runtime.GOARCH)

Error for a platform this build has no dynamic library loader binding for

Functions

func AddDLLDirectory

func AddDLLDirectory(dir string) (func(), error)

Nothing to add outside Windows, the returned function does nothing

func CString

func CString(s string) []byte

NUL terminated copy of s for a char pointer argument, to be kept referenced for as long as C reads it

func FindLibrary

func FindLibrary(name string) string

Soname or path the platform loader resolves for a short library name such as "opus", empty when none is installed

func GoString

func GoString(p uintptr) string

Copy of the NUL terminated C string at an address, empty for a null pointer

func Lookup

func Lookup(name string) (uintptr, error)

Address of a symbol in any library already loaded into the process

func NewCallback

func NewCallback(fn any) (cb uintptr, err error)

C function pointer that calls a Go function, never released; an error once the process has made as many as the platform allows

func PointerAt

func PointerAt(array uintptr, i int) uintptr

Pointer sized value at index i of a C array of pointers

func RegisterFunc

func RegisterFunc(fptr any, addr uintptr)

Binds a Go function variable to the C function at an address

Types

type Library

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

One loaded shared library, kept loaded for the life of the process

func Open

func Open(name string, global bool) (*Library, error)

Library opened through dlopen by name or path with every symbol bound at once, its symbols visible to libraries loaded later when global

func (*Library) Bind

func (l *Library) Bind(fptr any, name string) error

Binds a Go function variable to the library's function of that name, a SymbolError when the library lacks it

func (*Library) Symbol

func (l *Library) Symbol(name string) (uintptr, error)

Address of a symbol the library exports, a SymbolError carrying the loader's message when it does not

type LoadError

type LoadError struct {
	Name string
	Err  error
}

Shared library that could not be opened, with the reason the platform loader gave

func (*LoadError) Error

func (e *LoadError) Error() string

Loader's reason, led by the library name when the reason does not already mention it

func (*LoadError) Unwrap

func (e *LoadError) Unwrap() error

Loader's own error

type SymbolError

type SymbolError struct {
	Library string
	Symbol  string
	Err     error
}

Function or variable a library does not export, with the reason the platform loader gave

func (*SymbolError) Error

func (e *SymbolError) Error() string

Loader's reason, naming the symbol and the library when the reason does not already mention them

func (*SymbolError) Unwrap

func (e *SymbolError) Unwrap() error

Loader's own error

Jump to

Keyboard shortcuts

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