Standard library / go/scanner

go/scanner.Scanner

Stateful lexical scanner; initialize before scanning. Expected stdout: '0\n'.

Formal Syntax & Structure

go syntaxgo
type Scanner struct {
  ErrorCount int}

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/scanner"  "go/token")
func main() {  src := []byte("x := 1")  f := token.NewFileSet().AddFile("demo.go", -1, len(src))  var s scanner.Scanner  s.Init(f, src, nil, 0)  fmt.Println(s.ErrorCount)}
Go Reference