errorutil - ActiveState ActiveGo 1.8
...

Package errorutil

import "go4.org/errorutil"
Overview
Index

Overview ▾

Package errorutil helps make better error messages.

func HighlightBytePosition

func HighlightBytePosition(f io.Reader, pos int64) (line, col int, highlight string)

HighlightBytePosition takes a reader and the location in bytes of a parse error (for instance, from json.SyntaxError.Offset) and returns the line, column, and pretty-printed context around the error with an arrow indicating the exact position of the syntax error.