env HOME=$WORK/home

! unparam .
cmp stdout stdout.golden

-- go.mod --
module testdata.tld/foo
-- stdout.golden --
foo.go:13:42: nonPanicImpl - f is unused
foo.go:30:43: nonPanicImpl2 - f is unused
foo.go:49:19: nonConstImpl - f is unused
foo.go:49:31: nonConstImpl - s is unused
foo.go:53:28: oneOverwritten - i is unused
-- foo.go --
package foo

import (
	"errors"
	"log"
	"net/http"
)

func dummyImpl(f int) {}

func panicImpl(f int) { panic("dummy") }

func nonPanicImpl(w http.ResponseWriter, f int) {
	for i := 0; i < 10; i++ {
		w.Write([]byte("foo"))
	}
	panic("default")
}

func throw(v ...interface{}) {}

func throwImpl(f int) { throw("dummy") }

func endlessLoop(w http.ResponseWriter) {
	for {
		w.Write([]byte("foo"))
	}
}

func nonPanicImpl2(w http.ResponseWriter, f int) {
	endlessLoop(w)
	panic("unreachable")
}

func zeroImpl(f int) (int, string, []byte) { return 0, "", nil }

func errorsImpl(f int) error { return errors.New("unimpl") }

type fooError int

const constFoo = fooError(123)

func (f fooError) Error() string { return "foo" }

func customErrImpl(f fooError) error { return constFoo }

var iface interface{}

func nonConstImpl(f fooError, s string) error { return iface.(error) }

func logImpl(f int) { log.Print("not implemented") }

func oneOverwritten(a int, i uint8) (int, uint8) {
	i = 3
	a += 1
	return a, i
}

type fooStruct struct{
	field string
}

func zeroStructImpl(f fooStruct) fooStruct {
	return fooStruct{}
}

func zeroMapImpl(f int) map[int]int {
	return map[int]int{}
}

func zeroMapMakeImpl(f int) map[int]int {
	return make(map[int]int, 0)
}

func customError(msg string) error { return errors.New("custom: " + msg) }
func customErrorImpl(f fooError) (int8, error) {
	return -1, customError("x: bar")
}

func customErrorf(msg string) error { return errors.New("custom: " + msg) }
func customErrorfImpl(f fooError) (int8, error) {
	return -1, customErrorf("x: bar")
}
