package pkg

import (
	"bytes"
	"fmt"
	"io"
)

type NotAWriter struct{}

func (NotAWriter) Write(b []byte) {}

func fn1() {
	var w io.Writer
	var w2 NotAWriter

	fmt.Fprint(w, "abc", "de")   //@ diag(`Use fmt.Fprint`)
	fmt.Fprintf(w, "%T", w)      //@ diag(`Use fmt.Fprintf`)
	fmt.Fprintln(w, "abc", "de") //@ diag(`Use fmt.Fprintln`)

	w2.Write([]byte(fmt.Sprint("abc", "de")))
}

func fn2() {
	buf := new(bytes.Buffer)
	var sw io.StringWriter

	fmt.Fprint(buf, "abc", "de")   //@ diag(`Use fmt.Fprint`)
	fmt.Fprintf(buf, "%T", 0)      //@ diag(`Use fmt.Fprintf`)
	fmt.Fprintln(buf, "abc", "de") //@ diag(`Use fmt.Fprintln`)

	// We can't suggest fmt.Fprint here. We don't know if sw implements io.Writer.
	sw.WriteString(fmt.Sprint("abc", "de"))
	sw.WriteString(fmt.Sprintf("%T", 0))
	sw.WriteString(fmt.Sprintln("abc", "de"))
}

func fn3() {
	var buf bytes.Buffer
	fmt.Fprint(&buf, "abc", "de") //@ diag(`Use fmt.Fprint`)
}
