Skip to content

Commit

Permalink
Update word count example program (#79)
Browse files Browse the repository at this point in the history
Update word count example program to conform to API changes.
  • Loading branch information
jcharum authored Jun 22, 2020
1 parent cb37567 commit c06d4c9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit c06d4c9

Please sign in to comment.