mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
std: pass bytes.Buffer and strings.Builder by pointer
This CL fixes a number of (all true positive) findings of vet's
copylock analyzer patched to treat the Bu{ff,uild}er types
as non-copyable after first use.
This does require imposing an additional indirection
between noder.writer and Encoder since the field is
embedded by value but its constructor now returns a pointer.
Updates golang/go#25907
Updates golang/go#47276
Change-Id: I0b4d77ac12bcecadf06a91709e695365da10766c
Reviewed-on: https://go-review.googlesource.com/c/go/+/635339
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
da9c5b142c
commit
198c3cb785
6 changed files with 17 additions and 17 deletions
|
|
@ -354,7 +354,7 @@ func TestWriteAppend(t *testing.T) {
|
|||
got.Write(b)
|
||||
}
|
||||
if !Equal(got.Bytes(), want) {
|
||||
t.Fatalf("Bytes() = %q, want %q", got, want)
|
||||
t.Fatalf("Bytes() = %q, want %q", &got, want)
|
||||
}
|
||||
|
||||
// With a sufficiently sized buffer, there should be no allocations.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue