From 9eb16a52f20afcad9e0c7bcd4583567a88b2b56b Mon Sep 17 00:00:00 2001 From: Xargin Date: Thu, 21 Jul 2016 14:44:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8Ffix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch9/ch9-07.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ch9/ch9-07.md b/ch9/ch9-07.md index 428da9e..04a58b1 100644 --- a/ch9/ch9-07.md +++ b/ch9/ch9-07.md @@ -163,12 +163,13 @@ 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() res, ok := memo.cache[key] - if !ok { + if !ok { res.value, res.err = memo.f(key) memo.cache[key] = res }