Merge branch 'master' of github.com:chai2010/book-gopl-zh

pull/1/head
Xargin 2016-08-03 16:27:20 +08:00
commit 7372746639
1 changed files with 3 additions and 2 deletions

View File

@ -163,7 +163,8 @@ type Memo struct {
// Get is concurrency-safe.
func (memo *Memo) Get(key string) (value interface{}, err error) {
res, ok := memo.cache[key] if!ok{
res, ok := memo.cache[key]
if !ok {
res.value, res.err = memo.f(key)
memo.cache[key] = res
memo.mu.Lock()