From c06d4c90a9ed88e414181eb9ffe0d0fb302efef1 Mon Sep 17 00:00:00 2001 From: Jaran Charumilind Date: Mon, 22 Jun 2020 16:23:21 -0700 Subject: [PATCH] Update word count example program (#79) Update word count example program to conform to API changes. --- docs/index.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/index.md b/docs/index.md index 3a89a3b..950abea 100644 --- a/docs/index.md +++ b/docs/index.md @@ -118,15 +118,16 @@ const shakespeare = "https://ocw.mit.edu/ans7870/6"+ func main() { - sess, shutdown := sliceconfig.Parse() - defer shutdown() + sess := sliceconfig.Parse() + defer sess.Shutdown() ctx := context.Background() tokens, err := sess.Run(ctx, wordCount, shakespeare) if err != nil { log.Fatal(err) } - scan := tokens.Scan(ctx) + scanner := tokens.Scanner() + defer scanner.Close() type counted struct { token string count int @@ -136,10 +137,10 @@ func main() { count int counts []counted ) - for scan.Scan(ctx, &token, &count) { + for scanner.Scan(ctx, &token, &count) { counts = append(counts, counted{token, count}) } - if err := scan.Err(); err != nil { + if err := scanner.Err(); err != nil { log.Fatal(err) }