writer

package
v0.0.0-...-b91f67e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 8 Imported by: 0

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 BufWriter

type BufWriter interface {
	Writer
	Flush() error
}

BufWriter represents buffered error result writer.

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 errors {
	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 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 errors {
	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 errors {
	w.Write(e)
}
Output:

path/to/file1|1 col 14 warning| hello
path/to/file1|2 col 14 info| vim
file2|2 col 14 error 1| emacs
file2|14 col 1 error 14| neovim

func NewTemplate

func NewTemplate(tmpl *template.Template, w io.Writer) *Template

func (*Template) Write

func (t *Template) Write(e *errorformat.Entry) error

type Writer

type Writer interface {
	Write(*errorformat.Entry) error
}

Writer represents error result writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL