Example #1
0
func (db Db) PkgByName(name string) (*Package, error) {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))
	ptr := C.alpm_db_get_pkg(db.ptr, c_name)
	if ptr == nil {
		return nil,
			fmt.Errorf("Error when retrieving %s from database %s: %s",
				name, db.Name(), db.handle.LastError())
	}
	return &Package{ptr, db.handle}, nil
}
Example #2
0
func (db DB) FindPackage(name string) *Pkg {
	nameptr := C.CString(name)
	defer C.free(unsafe.Pointer(nameptr))

	pkgptr := C.alpm_db_get_pkg(db.ptr, nameptr)

	if pkgptr == nil {
		return nil
	}

	pkg := pointerToPkg(pkgptr)
	return pkg
}