func (kc *KCDB) Remove(key []byte) (err error) { ckey := (*C.char)(unsafe.Pointer(&key[0])) if C.kcdbremove(kc.db, ckey, C.size_t(len(key))) == 0 { err = kc.error() } return }
// Remove removes a record from the database by its key. // // Returns a KCError instance if there is no record for the given key, // or in case of other errors. The error instance contains a message // describing what happened func (d *DB) Remove(key string) error { if d.mode < WRITE { return KCError("The database was opened in read-only mode, you can't remove a record from it") } cKey := C.CString(key) defer C.free(unsafe.Pointer(cKey)) lKey := C.size_t(len(key)) status := C.kcdbremove(d.db, cKey, lKey) if status == 0 { errMsg := d.LastError() return KCError(fmt.Sprintf("Failed to remove the record with the key %s: %s", key, errMsg)) } return nil }