1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:54:42 -07:00

testing: give short package variable a longer name

(Update to CL 229837)

Change-Id: Ieab46bd384f76f678ef0d6a38dc043bc4b0c458a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230157
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2020-04-25 07:01:45 -07:00
parent a9f8f02f3c
commit 7ef28cbd12

View File

@ -797,10 +797,10 @@ func (c *common) Cleanup(f func()) {
}
}
var (
rOnce sync.Once
r *strings.Replacer
)
var tempDirReplacer struct {
sync.Once
r *strings.Replacer
}
// TempDir returns a temporary directory for the test to use.
// It is lazily created on first access, and calls t.Fatal if the directory
@ -814,10 +814,10 @@ func (c *common) TempDir() string {
// ioutil.TempDir doesn't like path separators in its pattern,
// so mangle the name to accommodate subtests.
rOnce.Do(func() {
r = strings.NewReplacer("/", "_", "\\", "_", ":", "_")
tempDirReplacer.Do(func() {
tempDirReplacer.r = strings.NewReplacer("/", "_", "\\", "_", ":", "_")
})
pattern := r.Replace(c.Name())
pattern := tempDirReplacer.r.Replace(c.Name())
c.tempDir, c.tempDirErr = ioutil.TempDir("", pattern)
if c.tempDirErr == nil {