commit | c264c87335ff4b3111d43f830dbe37eac1509f2e | [log] [tgz] |
---|---|---|
author | Brad Fitzpatrick <bradfitz@golang.org> | Thu Jan 22 14:15:47 2015 -0800 |
committer | Brad Fitzpatrick <bradfitz@golang.org> | Mon Apr 06 08:53:47 2015 +0000 |
tree | 72a631779b376ae0ec4b584453d4b07ba897bf02 | |
parent | c50a8416c851ab6897f9efcd932ac26b5862dcad [diff] |
bytes, strings: add Reader.Size methods As noted on recently on golang-nuts, there's currently no way to know the total size of a strings.Reader or bytes.Reader when using ReadAt on them. Most callers resort to wrapping it in an io.SectionReader to retain that information. The SizeReaderAt abstraction (an io.ReaderAt with a Size() int64 method) has proven useful as a way of expressing a concurrency-safe read-only number of bytes. As one example, see http://talks.golang.org/2013/oscon-dl.slide#49 and the rest of that presentation for its use in dl.google.com. SizeReaderAt is also used in the open source google-api-go-client, and within Google's internal codebase, where it exists in a public package created in 2013 with the package comment: "These may migrate to the standard library after we have enough experience with their feel." I'm still as happy with the SizeReaderAt abstraction and its composabilty as I was in 2013, so I'd like to make these two Readers also be SizeReaderAts. Fixes #9667 Change-Id: Ie6f145ada419dd116280472d8c029f046d5edf70 Reviewed-on: https://go-review.googlesource.com/3199 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
For documentation about how to install and use Go, visit https://golang.org/ or load doc/install-source.html in your web browser.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Please report issues here: https://golang.org/issue/new
Go is the work of hundreds of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
If you have just untarred a binary Go distribution, you need to set the environment variable $GOROOT to the full path of the go directory (the one containing this file). You can omit the variable if you unpack it into /usr/local/go, or if you rebuild from sources by running all.bash (see doc/install-source.html). You should also add the Go binary directory $GOROOT/bin to your shell's path.
For example, if you extracted the tar file into $HOME/go, you might put the following in your .profile:
export GOROOT=$HOME/go export PATH=$PATH:$GOROOT/bin
See https://golang.org/doc/install or doc/install.html for more details.