From 5dca9dfcfd461cb3c7b7af38454fec570c391b9b Mon Sep 17 00:00:00 2001 From: Lynn Date: Fri, 13 Oct 2017 04:08:33 -0500 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9defer=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BB=A3=E7=A0=81=E7=89=87=E6=AE=B5=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=20(#403)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eBook/12.7.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eBook/12.7.md b/eBook/12.7.md index f70f518..2dcfb5e 100644 --- a/eBook/12.7.md +++ b/eBook/12.7.md @@ -4,10 +4,10 @@ ```go func data(name string) string { - f := os.Open(name, os.O_RDONLY, 0) + f, _ := os.OpenFile(name, os.O_RDONLY, 0) defer f.Close() // idiomatic Go code! - contents := io.ReadAll(f) - return contents + contents, _ := ioutil.ReadAll(f) + return string(contents) } ```