# Keys

> USearch for Go

A key is 128 bits of opaque identity, rendered as a lowercase dashed UUID.
Keys need not be unique: several entries may share one, and `Count` reports how many.

```go
key := usearch.KeyFromUint64(42)
fmt.Println(key)                 // 00000000-0000-0000-0000-00000000002a
value, integral := key.Uint64()  // 42, true

parsed, err := usearch.ParseKey("00000000-0000-0000-0000-00000000002a")
```

Keys satisfy `encoding.TextMarshaler` and `encoding.TextUnmarshaler`, so they round-trip through JSON as those same strings.

`import "github.com/unum-cloud/USearch/golang"`

## Key

Key is a 128-bit entry identity, most significant byte first, rendered as a lowercase dashed UUID.

```go
type Key [16]byte
```

Keys need not be unique: several entries may share one, and DenseIndexOn.Count reports how
many. Integer identities park in the low eight bytes, so KeyFromUint64(42) prints as
00000000-0000-0000-0000-00000000002a.

## NilKey

NilKey is the all-zero key.

```go
var NilKey Key
```

## KeyFromUint64

KeyFromUint64 parks an integer identity in the low eight bytes, zeroing the rest.

```go
func KeyFromUint64(value uint64) Key
```

## ParseKey

ParseKey reads the rendering String produces.

```go
func ParseKey(text string) (Key, error)
```

Dashes may sit anywhere, or nowhere.

## AppendText

AppendText implements encoding.TextAppender.

```go
func (key Key) AppendText(buffer []byte) ([]byte, error)
```

## MarshalText

MarshalText implements encoding.TextMarshaler, so a key inside a struct round-trips through JSON as the dashed UUID String prints.

```go
func (key Key) MarshalText() ([]byte, error)
```

## String

String renders the key as a lowercase dashed UUID.

```go
func (key Key) String() string
```

## Uint64

Uint64 reports the integer identity in the low eight bytes, and false when the high eight carry anything.

```go
func (key Key) Uint64() (uint64, bool)
```

## UnmarshalText

UnmarshalText implements encoding.TextUnmarshaler.

```go
func (key *Key) UnmarshalText(text []byte) error
```

