Standard library / go/scanner

go/scanner.ErrorList.Less()

Compares two entries for sorting by position and message. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (p ErrorList) Less(i, j int) bool

Parameters & Attributes

NameTypeDescription
iintZero-based index among remaining positional arguments.
jintInput to the operation as described above.

Return Value

bool

Compares two entries for sorting by position and message.

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.Less(1, 0))}
Go Reference