Documentation
¶
Overview ¶
Package driver chooses how a library of lib/ runs in a program. It knows no library: a library's Go package lists its own drivers and asks Choose for one.
A driver is one way of reaching the library's code:
cgo the C library linked through cgo, fixed when the program is built c2go the C library translated to Go by ccgo, fixed when the program is built purego the C library as a shared library loaded when the program runs (cengine/library) go a legacy pure-Go implementation, where the library still provides one
Choose prefers them in that order. A program names one, or asks for the best available one with Auto; FromEnvironment reads the name from EXT_ENGINE. Asking for a driver by name never gets another one: a name that cannot be served is an error.
Index ¶
Constants ¶
const Environment = "EXT_ENGINE"
Environment is the variable FromEnvironment reads: a driver name, or auto (the default).
Variables ¶
var ( // ErrUnknown is a name that is not a driver. ErrUnknown = errors.New("unknown driver") ErrUnavailable = errors.New("driver unavailable") )
Functions ¶
func Choose ¶
Choose returns the driver called want from drivers, or with Auto (or an empty name) the first available one, in Order, for which fits returns nil. fits says why an available driver does not serve the caller, such as a missing feature; nil fits accepts every available driver. A named driver that is missing from drivers, unavailable or rejected by fits is an error, never another driver.
Types ¶
type Driver ¶
type Driver interface {
Name() Name
// Available reports whether this build and this machine hold the driver.
Available() bool
}
Driver is what a library's Go package lists for each way it can run.