Standard library / go/scanner
go/scanner.PrintError()
Prints an ErrorList one diagnostic per line, or a single error string. Expected stdout: 'demo.go:1:1: first\ndemo.go:2:1: second\n'.
Formal Syntax & Structure
go syntaxgo
func PrintError(w io.Writer, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Destination writer. |
| err | error | Error callback for scanning, or error to print. |
Working Example
Example Snippetgo
package main
import ( "go/scanner" "go/token" "os")
func main() { var es scanner.ErrorList es.Add(token.Position{Filename: "demo.go", Line: 2, Column: 1}, "second") es.Add(token.Position{Filename: "demo.go", Line: 1, Column: 1}, "first") es.Sort() scanner.PrintError(os.Stdout, es)}