Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
a45c657d
Commit
a45c657d
authored
Aug 26, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes.Buffer: clarify that NewBuffer is not for beginners
R=golang-dev, adg CC=golang-dev
https://golang.org/cl/4965048
parent
ebf19fb1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
buffer.go
src/pkg/bytes/buffer.go
+6
-1
No files found.
src/pkg/bytes/buffer.go
View file @
a45c657d
...
@@ -338,11 +338,16 @@ func (b *Buffer) ReadString(delim byte) (line string, err os.Error) {
...
@@ -338,11 +338,16 @@ func (b *Buffer) ReadString(delim byte) (line string, err os.Error) {
// contents. It is intended to prepare a Buffer to read existing data. It
// contents. It is intended to prepare a Buffer to read existing data. It
// can also be used to size the internal buffer for writing. To do that,
// can also be used to size the internal buffer for writing. To do that,
// buf should have the desired capacity but a length of zero.
// buf should have the desired capacity but a length of zero.
//
// In most cases, new(Buffer) (or just declaring a Buffer variable) is
// preferable to NewBuffer. In particular, passing a non-empty buf to
// NewBuffer and then writing to the Buffer will overwrite buf, not append to
// it.
func
NewBuffer
(
buf
[]
byte
)
*
Buffer
{
return
&
Buffer
{
buf
:
buf
}
}
func
NewBuffer
(
buf
[]
byte
)
*
Buffer
{
return
&
Buffer
{
buf
:
buf
}
}
// NewBufferString creates and initializes a new Buffer using string s as its
// NewBufferString creates and initializes a new Buffer using string s as its
// initial contents. It is intended to prepare a buffer to read an existing
// initial contents. It is intended to prepare a buffer to read an existing
// string.
// string.
See the warnings about NewBuffer; similar issues apply here.
func
NewBufferString
(
s
string
)
*
Buffer
{
func
NewBufferString
(
s
string
)
*
Buffer
{
return
&
Buffer
{
buf
:
[]
byte
(
s
)}
return
&
Buffer
{
buf
:
[]
byte
(
s
)}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment