From 8d6c4fdc81bbb1b77df9455908d898937990febc Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 13 Apr 2012 15:51:39 -0700 Subject: [PATCH] errorutil: write docs Change-Id: I23b60fe920a897427c4d473fd8c7c9ba6ee40d44 --- pkg/errorutil/highlight.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/errorutil/highlight.go b/pkg/errorutil/highlight.go index 8b36bb77b..aace6a46c 100644 --- a/pkg/errorutil/highlight.go +++ b/pkg/errorutil/highlight.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package errorutil helps make better error messages. package errorutil import ( @@ -24,7 +25,11 @@ import ( "strings" ) -func HighlightBytePosition(f io.Reader, pos int64) (line int, 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. +func HighlightBytePosition(f io.Reader, pos int64) (line, col int, highlight string) { line = 1 br := bufio.NewReader(f) lastLine := ""