Standard library / go/scanner

go/scanner.ErrorList.Error()

Summarizes the first diagnostic and the number of additional errors. Expected stdout: 'demo.go:2:1: second (and 1 more errors)\n'.

Formal Syntax & Structure

go syntaxgo
func (p ErrorList) Error() string

Return Value

string

Summarizes the first diagnostic and the number of additional errors.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/scanner"  "go/token")
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")  fmt.Println(es.Error())}
Go Reference