Fix a bug in OncePer.Get that could return a waiter

OncePer.Get must call maybeWaitFor on the value it reads, otherwise
it could return a waiter instead of the real value.

Test: onceper_test.go
Change-Id: I7d407bd1c577dbb43bc14fa107d5f606bf2b1c67
This commit is contained in:
Colin Cross
2019-02-15 23:00:48 -08:00
parent 4f41bc2bed
commit d7cfaeeebc
2 changed files with 32 additions and 1 deletions

View File

@@ -70,7 +70,7 @@ func (once *OncePer) Get(key OnceKey) interface{} {
panic(fmt.Errorf("Get() called before Once()"))
}
return v
return once.maybeWaitFor(key, v)
}
// OnceStringSlice is the same as Once, but returns the value cast to a []string