File: template_test.go

package info (click to toggle)
golang-github-reviewdog-errorformat 0.0~git20220309.b075c45-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 900 kB
  • sloc: python: 59; xml: 13; javascript: 4; sh: 4; haskell: 3; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 795 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package writer

import (
	"os"
	"text/template"
)

func ExampleTemplate_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
}

func ExampleTemplate_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
}