internal: use atomic type (#27858)

This commit is contained in:
ucwong 2023-08-07 08:11:06 +01:00 committed by GitHub
parent 60070fe5c6
commit 857476753d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,13 +55,13 @@ type TestCmd struct {
Err error
}
var id int32
var id atomic.Int32
// Run exec's the current binary using name as argv[0] which will trigger the
// reexec init function for that name (e.g. "geth-test" in cmd/geth/run_test.go)
func (tt *TestCmd) Run(name string, args ...string) {
id := atomic.AddInt32(&id, 1)
tt.stderr = &testlogger{t: tt.T, name: fmt.Sprintf("%d", id)}
id.Add(1)
tt.stderr = &testlogger{t: tt.T, name: fmt.Sprintf("%d", id.Load())}
tt.cmd = &exec.Cmd{
Path: reexec.Self(),
Args: append([]string{name}, args...),