August 2019
Beginner to intermediate
798 pages
17h 2m
English
A scanner is something, which in this case will be some Go code, that reads a program written in a programming language, which in this case is Go, and generates tokens.
The go/scanner package is used for reading Go programs and generating a series of tokens. The use of the go/scanner package will be illustrated in goScanner.go, which will be presented in three parts.
The first part of goScanner.go is as follows:
package main
import (
"fmt"
"go/scanner"
"go/token"
"io/ioutil"
"os"
)
func main() {
if len(os.Args) == 1 {
fmt.Println("Not enough arguments!")
return
}
The go/token package defines constants that represent the lexical tokens of the Go programming language.
The second part of goScanner.go contains the following ...
Read now
Unlock full access