Skip to content

Commit 0ac8739

Browse files
author
Bryan C. Mills
committed
cmd/fix: eliminate data races in TestRewrite and gofmt
Fixes #35632 Change-Id: I55c3d53c2a6240868ec001866047a15ec8f91809 Reviewed-on: https://go-review.googlesource.com/c/go/+/207603 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent afac2c0 commit 0ac8739

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/cmd/fix/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ func processFile(filename string, useStdin bool) error {
203203
return ioutil.WriteFile(f.Name(), newSrc, 0)
204204
}
205205

206-
var gofmtBuf bytes.Buffer
207-
208206
func gofmt(n interface{}) string {
209-
gofmtBuf.Reset()
207+
var gofmtBuf bytes.Buffer
210208
if err := format.Node(&gofmtBuf, fset, n); err != nil {
211209
return "<" + err.Error() + ">"
212210
}

src/cmd/fix/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func parseFixPrint(t *testing.T, fn func(*ast.File) bool, desc, in string, mustB
7676

7777
func TestRewrite(t *testing.T) {
7878
for _, tt := range testCases {
79+
tt := tt
7980
t.Run(tt.Name, func(t *testing.T) {
8081
t.Parallel()
8182
// Apply fix: should get tt.Out.

0 commit comments

Comments
 (0)