github.com/rhysd/locerr (go): Package locerr is a small library to make an error with source code location information. It provides a struct to represent a source file, a specific position in code and an error related to specific range or position in source.  It's important to make a good error when compilation or execution errors found. locerr helps it. This library is actually used in some my compiler implementation.  Repository: https://github.com/rhysd/locerr  At first you should gain entire source as *Source instance.  You can get *Source instance from file (NewSourceFromFile) or stdin (NewSourceFromStdin) also.  Let's say to find an error at some range in the source.  ErrorIn or other factory functions make a new error instance with the range. Error instance implements error interface so it can be handled like other error types.  Assume that you find additional information (location of variable and its type). Then you can add some notes to the error. Notes can be added by wrapping errors like pkg/errors library.  Finally you can see the result! err.Error() gets the error message as string. Note that this is only for non-Windows OS.  It should output following:  To support Windows, please use PrintToFile() method. It directly writes the error message into given file. This supports Windows and is useful to output from stdout or stderr.  Labels such as 'Error:' or 'Notes:' are colorized. Main error message is emphasized with bold font. And source code location information (file name, line and column) is added with gray text. If the error has range information, the error shows code snippet which caused the error at the end of error message  Colorized output can be seen at https://github.com/rhysd/ss/blob/master/locerr/output.png?raw=true  If you have only one position information rather than two, 'start' position and 'end' position, ErrorAt() is available instead of ErrorIn() ErrorAt() takes one Pos instance.  In this case, line snippet is shown in error message. `pos.Line` is used to get line from source text.  It should output following:
Keywords: error|go|golang|source