# Pick the right one: int vs. int64

## int

An **index**, **length** or **capacity** should normally be an `int`

.
The `int`

type is either 32 or 64 bits, and always big enough
to hold the maximum possible length of an array.

## int64 and friends

The types `int8`

, `int16`

, `int32`

, and `int64`

(and their
unsigned counterparts) are best suited for **data**.
An `int64`

is the typical choice when memory isn’t an issue.

In particular, you can use a ** byte**, which is an alias for

`uint8`

,
to be extra clear about your intent.
Similary, you can use a **, which is an alias for**

`rune`

`int32`

,
to emphasize than an integer represents a code point.## Examples

In this code, the slice elements and the `max`

variable have type `int64`

,
while the index and the length of the slice have type `int`

.

```
func Max(a []int64) int64 {
max := a[0]
for i := 1; i < len(a); i++ {
if max < a[i] {
max = a[i]
}
}
return max
}
```

The implementation of `time.Duration`

is a typical example from the standard library:

```
type Duration int64
```

A `Duration`

represents the time between two instants
as a nanosecond count. This limits the
largest possible duration to about 290 years.

### Further reading

The Maximum value of an int article
shows how to compute the size and limit values of an `int`

as untyped constants.