Skip to content

Instantly share code, notes, and snippets.

@atotto
Created July 12, 2014 05:56
Show Gist options
  • Save atotto/cd0090110fe54745c891 to your computer and use it in GitHub Desktop.
Save atotto/cd0090110fe54745c891 to your computer and use it in GitHub Desktop.
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