Documentation
¶
Overview ¶
Package loader opens speech.cpp's shared library, libspeech, at run time and checks that its C API is one this module was written against.
It does not use cgo: the library is opened with dlopen (purego) on Unix and LoadLibrary on Windows, from a path the caller gives.
Index ¶
Constants ¶
const ( RequiredMajor = 4 RequiredMinor = 3 )
The C API version this module binds: speech.h of speech.cpp 0.11.3. A library of the same major version and a minor version of at least RequiredMinor is accepted.
Variables ¶
var ErrIncompatibleVersion = errors.New("loader: incompatible libspeech API version")
ErrIncompatibleVersion is the sentinel every *VersionError matches with errors.Is.
var ErrNoLibrary = errors.New("loader: no libspeech in directory")
ErrNoLibrary is returned when a directory holds no file with one of LibraryFilenames' names.
Functions ¶
func CheckVersion ¶
CheckVersion returns a *VersionError when major.minor is not compatible with RequiredMajor.RequiredMinor: another major version, or a lower minor one. path only names the library in the error.
func LibraryFilenames ¶
LibraryFilenames returns the file names libspeech has on goos, the versioned name (its SOVERSION) first.
Types ¶
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library is an open libspeech whose C API version has been checked. Nothing a library hands out may outlive it, so one whose functions are in use stays open for the life of the process; Close is for one that is not.
func Open ¶
Open opens libspeech at path, a file or a directory holding it, reads speech_api_version_major() and speech_api_version_minor(), and refuses a library whose version CheckVersion refuses, with a *VersionError.
func (*Library) APIVersion ¶
APIVersion is the C API version the library reported.
func (*Library) Close ¶
Close closes the library (dlclose, FreeLibrary). It is only for a library none of whose functions or objects are in use, such as one whose symbols could not all be bound. A second Close does nothing. It is not safe to call while another goroutine uses the Library.
type VersionError ¶
type VersionError struct {
Path string
FoundMajor int
FoundMinor int
RequiredMajor int
RequiredMinor int
}
VersionError says that the library's C API version is not one this module runs against.
func (*VersionError) Error ¶
func (e *VersionError) Error() string
func (*VersionError) Unwrap ¶
func (e *VersionError) Unwrap() error
Unwrap makes errors.Is(err, ErrIncompatibleVersion) true.