Documentation ¶
Overview ¶
Package dl implements loading shared libraries and binding functions
/✱ int function(int); #define DEFINE_JUMPER(x) \ void *_godl_##x = (void*)0; \ __asm__(".global "#x"\n\t"#x":\n\tmovq _godl_"#x"(%rip),%rax\n\tjmp *%rax\n") DEFINE_JUMPER(function) ✱/ import "C" import ( "github.com/sudachen/go-dl/dl" "runtime" "unsafe" ) func init() { if runtime.GOOS == "linux" && runtime.GOARCH == "amd64"{ so := dl.Load( dl.Cache("dl/go-dl/libfunction.so"), dl.LzmaExternal("https://github.com/sudachen/go-dl/releases/download/initial/libfunction_lin64.lzma")) } else if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" { so := dl.Load( dl.Cache("dl/go-dl/function.dll"), dl.LzmaExternal("https://github.com/sudachen/go-dl/releases/download/initial/libfunction_win64.lzma")) } so.Bind("function",unsafe.Pointer(&C._godl_function)) } func main() { C.function(0) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cached ¶
type Cached string
Cached specifies cache file and enables loading file from the Internet
type GzipExternal ¶
type GzipExternal string
GzipExternal specifies url to the Gzip compressed shared library
type LzmaExternal ¶
type LzmaExternal string
LzmaExternal specifies url to the LZMA2 compressed shared library
type SO ¶
type SO struct {
// contains filtered or unexported fields
}
SO object incapacitates shared library handle
func Load ¶
func Load(a ...interface{}) SO
Load finds and loads shared library. Can download library form the Internet if it's required
Click to show internal directories.
Click to hide internal directories.