errorutil: write docs

Change-Id: I23b60fe920a897427c4d473fd8c7c9ba6ee40d44
This commit is contained in:
Brad Fitzpatrick 2012-04-13 15:51:39 -07:00
parent 6a8a5e197e
commit 8d6c4fdc81
1 changed files with 6 additions and 1 deletions

View File

@ -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 := ""