1
0
mirror of https://github.com/golang/go synced 2024-09-29 14:14:29 -06:00

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 <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Bryan C. Mills 2019-11-18 09:54:45 -05:00
parent afac2c0508
commit 0ac8739ad5
2 changed files with 2 additions and 3 deletions

View File

@ -203,10 +203,8 @@ func processFile(filename string, useStdin bool) error {
return ioutil.WriteFile(f.Name(), newSrc, 0)
}
var gofmtBuf bytes.Buffer
func gofmt(n interface{}) string {
gofmtBuf.Reset()
var gofmtBuf bytes.Buffer
if err := format.Node(&gofmtBuf, fset, n); err != nil {
return "<" + err.Error() + ">"
}

View File

@ -76,6 +76,7 @@ func parseFixPrint(t *testing.T, fn func(*ast.File) bool, desc, in string, mustB
func TestRewrite(t *testing.T) {
for _, tt := range testCases {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
// Apply fix: should get tt.Out.