Skip to content

spec: set capacity of slice #1642

Closed
Closed
@rogpeppe

Description

@rogpeppe
See this discussion:
http://groups.google.com/group/golang-dev/browse_thread/thread/db5a0502ed9e40d6

Sometimes when returning a slice it would be useful
to be able to set its capacity.

For instance, it would be easy to (wrongly) pass a slice returned from
bufio.ReadSlice to bytes.NewBuffer and then write to that buffer,
overwriting the next line.

If ReadSlice could set the capacity of the returned slice, this
would not be an issue.

A possible syntax for this would be

x[start : length : capacity]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions