github.com/notti/nocgo@v0.0.0-20190619201224-fc443047424c/internal/dlopen/dlopencgo.go (about) 1 // +build cgo 2 3 package dlopen 4 5 // #cgo LDFLAGS: -ldl 6 // #include <dlfcn.h> 7 import "C" 8 import "unsafe" 9 10 func DLOpen(filename []byte, flags int32) uintptr { 11 return uintptr(C.dlopen((*C.char)(unsafe.Pointer(&filename[0])), C.int(flags))) 12 } 13 14 func DLClose(handle uintptr) int32 { 15 return int32(C.dlclose(unsafe.Pointer(handle))) 16 } 17 18 func DLSym(handle uintptr, symbol []byte) uintptr { 19 return uintptr(C.dlsym(unsafe.Pointer(handle), (*C.char)(unsafe.Pointer(&symbol[0])))) 20 } 21 22 func DLError() uintptr { 23 return uintptr(unsafe.Pointer(C.dlerror())) 24 }