Skip to content

Commit ce96388

Browse files
authored
Merge pull request #204 from onflow/holyfuchs/fix-race-condition
fix race conditions
2 parents fac2681 + 9bce78d commit ce96388

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

config/config.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,15 @@ func (c *Config) Validate() error {
9494
return nil
9595
}
9696

97-
// Default returns the default configuration.
97+
// Default returns a *copy* of the default configuration.
9898
func Default() *Config {
99-
return &Config{
100-
Emulators: DefaultEmulators,
101-
Networks: DefaultNetworks,
99+
cfg := &Config{
100+
Emulators: make(Emulators, len(DefaultEmulators)),
101+
Networks: make(Networks, len(DefaultNetworks)),
102102
}
103+
copy(cfg.Emulators, DefaultEmulators)
104+
copy(cfg.Networks, DefaultNetworks)
105+
return cfg
103106
}
104107

105108
var ErrOutdatedFormat = errors.New("you are using old configuration format")

output/spinner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func (s *Spinner) run() {
7575
spinnerCharset[i%len(spinnerCharset)],
7676
s.suffix,
7777
)
78+
mu.Lock()
7879
_ = writer.Flush()
80+
mu.Unlock()
7981
i++
8082
}
8183
}

0 commit comments

Comments
 (0)