Skip to content

replace []Issue with []*Issue #180

Closed
@rsc

Description

@rsc

In general having slices of large structs is awkward because it means that when you range over the slice, you either have to write:

for i := range list {
    x := &list[i]
    ...
}

or you write

for _, x := range list {
    ...
}

and put up with the fact that (1) the iteration is doing a (more expensive than pointer copy) struct copy for each element and (2) you cannot modify the elements by changing x, since x is a copy.

If list were a []*github.Issue it wouldn't have these problems.

The encoding/json package can handle slices of pointers just fine, but changing the types would have the drawback of breaking existing clients.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions