Created
July 12, 2014 05:56
-
-
Save atotto/cd0090110fe54745c891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example_test | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"testing" | |
"text/scanner" | |
) | |
func TestTextScanner(t *testing.T) { | |
var s scanner.Scanner | |
f, err := os.Open("textscanner_example_test.go") | |
if err != nil { | |
log.Fatal(err) | |
} | |
s.Init(f) | |
tok := s.Scan() | |
for tok != scanner.EOF { | |
// do something with tok | |
tok = s.Scan() | |
fmt.Println(s.TokenText()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment