Documentation
¶
Overview ¶
Package errorformat provides 'errorformat' functionality of Vim. :h errorformat
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Efm ¶
type Efm struct {
// contains filtered or unexported fields
}
Efm represents a errorformat.
type Entry ¶
type Entry struct {
// name of a file
Filename string `json:"filename"`
// line number
Lnum int `json:"lnum"`
// End of line number if the item is multiline
EndLnum int `json:"end_lnum"`
// column number (first column is 1)
Col int `json:"col"`
// End of column number if the item has range
EndCol int `json:"end_col"`
// true: "col" is visual column
// false: "col" is byte index
Vcol bool `json:"vcol"`
// error number
Nr int `json:"nr"`
// search pattern used to locate the error
Pattern string `json:"pattern"`
// description of the error
Text string `json:"text"`
// type of the error, 'E', '1', etc.
Type rune `json:"type"`
// true: recognized error message
Valid bool `json:"valid"`
// Original error lines (often one line. more than one line for multi-line
// errorformat. :h errorformat-multi-line)
Lines []string `json:"lines"`
}
Entry represents matched entry of errorformat, equivalent to Vim's quickfix list item.
type Errorformat ¶
type Errorformat struct {
Efms []*Efm
}
Errorformat provides errorformat feature.
Example ¶
package main
import (
"fmt"
"strings"
"github.com/reviewdog/errorformat"
)
func main() {
in := `
golint.new.go:3:5: exported var V should have comment or be unexported
golint.new.go:5:5: exported var NewError1 should have comment or be unexported
golint.new.go:7:1: comment on exported function F should be of the form "F ..."
golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."
`
efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`, `%-G%.%#`})
s := efm.NewScanner(strings.NewReader(in))
for s.Scan() {
fmt.Println(s.Entry())
}
}
Output: golint.new.go|3 col 5| exported var V should have comment or be unexported golint.new.go|5 col 5| exported var NewError1 should have comment or be unexported golint.new.go|7 col 1| comment on exported function F should be of the form "F ..." golint.new.go|11 col 1| comment on exported function F2 should be of the form "F2 ..."
func NewErrorformat ¶
func NewErrorformat(efms []string) (*Errorformat, error)
NewErrorformat compiles given errorformats string (efms) and returns a new Errorformat. It returns error if the errorformat is invalid.
func (*Errorformat) NewScanner ¶
func (errorformat *Errorformat) NewScanner(r io.Reader) *Scanner
NewScanner returns a new Scanner to read from r.
type Match ¶
type Match struct {
F string // (%f) file name
N int // (%n) error number
L int // (%l) line number
C int // (%c) column number
T byte // (%t) error type
M string // (%m) error message
R string // (%r) the "rest" of a single-line file message
P string // (%p) pointer line
V int // (%v) virtual column number
S string // (%s) search text
// Extensions
E int // (%e) end line number
K int // (%k) end column number
}
Match represents match of Efm. ref: Basic items in :h errorformat
type Scanner ¶
type Scanner struct {
*Errorformat
// contains filtered or unexported fields
}
Scanner provides a interface for scanning compiler/linter/static analyzer result using Errorformat.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
errorformat
command
|
|
|
Package fmts holds defined errorformats.
|
Package fmts holds defined errorformats. |
|
Package writer provides error result writers.
|
Package writer provides error result writers. |
Click to show internal directories.
Click to hide internal directories.