Skip to content

Commit

Permalink
Merge pull request moby#12214 from ahmetalpbalkan/namesgenerator/loca…
Browse files Browse the repository at this point in the history
…lrand

names-generator: use local random instance
  • Loading branch information
cpuguy83 committed Apr 14, 2015
2 parents 7b29a88 + 25fab69 commit 040176f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/namesgenerator/names-generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,19 @@ var (
// Ada Yonath - an Israeli crystallographer, the first woman from the Middle East to win a Nobel prize in the sciences. https://en.wikipedia.org/wiki/Ada_Yonath
"yonath",
}

rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
)

func GetRandomName(retry int) string {
rand.Seed(time.Now().UnixNano())

begin:
name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))])
name := fmt.Sprintf("%s_%s", left[rnd.Intn(len(left))], right[rnd.Intn(len(right))])
if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
goto begin
}

if retry > 0 {
name = fmt.Sprintf("%s%d", name, rand.Intn(10))
name = fmt.Sprintf("%s%d", name, rnd.Intn(10))
}
return name
}

0 comments on commit 040176f

Please sign in to comment.