Documentation ¶
Overview ¶
Package writer provides error result writers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckStyle ¶
type CheckStyle struct {
// contains filtered or unexported fields
}
CheckStyle represents checkstyle XML writer. http://checkstyle.sourceforge.net/
Example ¶
w := NewCheckStyle(os.Stdout) for _, e := range testErrs { w.Write(e) } w.Flush()
Output: <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.0"> <file name="file2"> <error column="14" line="2" message="emacs" severity="error 1" source="E1"></error> <error column="1" line="14" message="neovim" severity="error 14" source="E14"></error> </file> <file name="path/to/file1"> <error column="14" line="1" message="hello" severity="warning"></error> <error column="14" line="2" message="vim" severity="info"></error> </file> </checkstyle>
func NewCheckStyle ¶
func NewCheckStyle(w io.Writer) *CheckStyle
func (*CheckStyle) Flush ¶
func (c *CheckStyle) Flush() error
func (*CheckStyle) Write ¶
func (c *CheckStyle) Write(e *errorformat.Entry) error
type JSONL ¶
type JSONL struct {
// contains filtered or unexported fields
}
JSONL represents JSONL (http://jsonlines.org/) based writer.
Example ¶
w := NewJSONL(os.Stdout) for _, e := range testErrs { w.Write(e) }
Output: {"filename":"path/to/file1","lnum":1,"end_lnum":2,"col":14,"end_col":15,"vcol":false,"nr":0,"pattern":"","text":"hello","type":87,"valid":false,"lines":["path/to/file1:1:14:[W] hello"]} {"filename":"path/to/file1","lnum":2,"end_lnum":0,"col":14,"end_col":0,"vcol":false,"nr":0,"pattern":"","text":"vim","type":73,"valid":false,"lines":["path/to/file1:2:14:[I] vim"]} {"filename":"file2","lnum":2,"end_lnum":0,"col":14,"end_col":0,"vcol":false,"nr":1,"pattern":"","text":"emacs","type":69,"valid":false,"lines":["file2:2:14:[E] emacs"]} {"filename":"file2","lnum":14,"end_lnum":0,"col":1,"end_col":0,"vcol":false,"nr":14,"pattern":"","text":"neovim","type":69,"valid":false,"lines":["file2:14:1:[E] neovim"]}
type Sarif ¶
type Sarif struct {
// contains filtered or unexported fields
}
Example ¶
w, _ := NewSarif(os.Stdout, SarifOption{ToolName: "super-linter"}) for _, e := range testErrs { w.Write(e) } w.Flush()
Output: { "$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.4", "runs": [ { "results": [ { "level": "warning", "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "path/to/file1", "uriBaseId": "%SRCROOT%" }, "region": { "endColumn": 15, "endLine": 2, "startColumn": 14, "startLine": 1 } } } ], "message": { "text": "hello" } }, { "level": "note", "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "path/to/file1", "uriBaseId": "%SRCROOT%" }, "region": { "startColumn": 14, "startLine": 2 } } } ], "message": { "text": "vim" } }, { "level": "error", "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "file2", "uriBaseId": "%SRCROOT%" }, "region": { "startColumn": 14, "startLine": 2 } } } ], "message": { "text": "emacs" } }, { "level": "error", "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "file2", "uriBaseId": "%SRCROOT%" }, "region": { "startColumn": 1, "startLine": 14 } } } ], "message": { "text": "neovim" } } ], "tool": { "driver": { "name": "super-linter" } } } ], "version": "2.1.0" }
type SarifOption ¶
type SarifOption struct {
ToolName string
}
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template represents text/template based writer.
Example (More) ¶
tmpl, _ := template.New("example").Parse("file:{{.Filename}}\tline:{{.Lnum}}\tcol:{{.Col}}\tmes:{{.Text}}") w := NewTemplate(tmpl, os.Stdout) for _, e := range testErrs { w.Write(e) }
Output: file:path/to/file1 line:1 col:14 mes:hello file:path/to/file1 line:2 col:14 mes:vim file:file2 line:2 col:14 mes:emacs file:file2 line:14 col:1 mes:neovim
Example (String) ¶
tmpl, _ := template.New("example").Parse("{{.String}}") w := NewTemplate(tmpl, os.Stdout) for _, e := range testErrs { w.Write(e) }
Output: path/to/file1|1-2 col 14-15 warning| hello path/to/file1|2 col 14 info| vim file2|2 col 14 error 1| emacs file2|14 col 1 error 14| neovim
type Writer ¶
type Writer interface {
Write(*errorformat.Entry) error
}
Writer represents error result writer.
Click to show internal directories.
Click to hide internal directories.