internal/scan: remove source field from TextHandler
Change-Id: I169389447f65e88b6b40cb63cf7b2f1992601e4a
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/495864
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Auto-Submit: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Julie Qiu <julieqiu@google.com>
diff --git a/internal/scan/print_test.go b/internal/scan/print_test.go
index 1305b34..f8531cd 100644
--- a/internal/scan/print_test.go
+++ b/internal/scan/print_test.go
@@ -27,7 +27,7 @@
rawJSON, _ := fs.ReadFile(testdata, input)
wantText, _ := fs.ReadFile(testdata, name+".txt")
got := &strings.Builder{}
- testRunHandler(t, rawJSON, scan.NewTextHandler(got, name != "binary"))
+ testRunHandler(t, rawJSON, scan.NewTextHandler(got))
if diff := cmp.Diff(string(wantText), got.String()); diff != "" {
t.Errorf("Readable mismatch (-want, +got):\n%s", diff)
}
diff --git a/internal/scan/run.go b/internal/scan/run.go
index c23d360..869f2d9 100644
--- a/internal/scan/run.go
+++ b/internal/scan/run.go
@@ -42,7 +42,7 @@
case cfg.json:
handler = govulncheck.NewJSONHandler(stdout)
default:
- th := NewTextHandler(stdout, cfg.mode == modeSource)
+ th := NewTextHandler(stdout)
th.Show = cfg.show
handler = th
}
@@ -130,9 +130,7 @@
// convertJSONToText converts r, which is expected to be the JSON output of govulncheck,
// into the text output, and writes the output to w.
func convertJSONToText(r io.Reader, w io.Writer) error {
- // TODO: instead of hardcoding source=true, determine source based on the
- // config decoded from the JSON output.
- h := NewTextHandler(w, true)
+ h := NewTextHandler(w)
if err := govulncheck.HandleJSON(r, h); err != nil {
return err
}
diff --git a/internal/scan/text.go b/internal/scan/text.go
index d5610b7..7ffedec 100644
--- a/internal/scan/text.go
+++ b/internal/scan/text.go
@@ -18,11 +18,8 @@
var templateFS embed.FS
// NewtextHandler returns a handler that writes govulncheck output as text.
-func NewTextHandler(w io.Writer, source bool) *TextHandler {
- return &TextHandler{
- w: w,
- source: source,
- }
+func NewTextHandler(w io.Writer) *TextHandler {
+ return &TextHandler{w: w}
}
type TextHandler struct {
@@ -31,7 +28,6 @@
w io.Writer
osvs []*osv.Entry
findings []*govulncheck.Finding
- source bool
}
const (