Example #1
0
// Initialize
func Init(root, dbpath string) (*Handle, error) {
	c_root := C.CString(root)
	defer C.free(unsafe.Pointer(c_root))
	c_dbpath := C.CString(dbpath)
	defer C.free(unsafe.Pointer(c_dbpath))
	var c_err C.alpm_errno_t
	h := C.alpm_initialize(c_root, c_dbpath, &c_err)

	if c_err != 0 {
		return nil, Error(c_err)
	}

	return &Handle{h}, nil
}
Example #2
0
func Init() (*Handle, error) {
	c_root := C.CString("/")
	defer C.free(unsafe.Pointer(c_root))

	c_dbpath := C.CString("/var/lib/pacman")
	defer C.free(unsafe.Pointer(c_dbpath))

	var errno C.alpm_errno_t
	h := C.alpm_initialize(c_root, c_dbpath, &errno)

	if errno != 0 {
		return nil, strerror(errno)
	}

	return &Handle{h}, nil
}