// Key ... func (curs *Cursor) Key() (key []byte, err error) { var n C.int res := C.unqlite_kv_cursor_key(curs.handle, nil, &n) if res != C.UNQLITE_OK { err = UnQLiteError(res) return } key = make([]byte, int(n)) res = C.unqlite_kv_cursor_key(curs.handle, unsafe.Pointer(&key[0]), &n) if res != C.UNQLITE_OK { err = UnQLiteError(res) } return }
// get key from the cursor, key can be nil func (c *Cursor) Key(key []byte) ([]byte, error) { var k unsafe.Pointer outlen := C.int(len(key)) if outlen == 0 { e := C.unqlite_kv_cursor_key(c.c, nil, &outlen) if e != C.UNQLITE_OK { return nil, code2Error(e) } key = make([]byte, outlen) } k = unsafe.Pointer(&key[0]) e := C.unqlite_kv_cursor_key(c.c, k, &outlen) if e != C.UNQLITE_OK { return nil, code2Error(e) } return key[:outlen], code2Error(e) }