Description
What version of Go are you using (go version
)?
$ go version go version go1.13.3 linux/amd64
Does this issue reproduce with the latest release?
not a bug, but a commenting feature request
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/spotter/.cache/go-build" GOENV="/home/spotter/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/spotter/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build007852437=/tmp/go-build -gno-record-gcc-switches"
What did you do?
using an inteface and had IDE implement missing interface functions
What did you expect to see?
usable functions that don't just panic
What did you see instead?
functions that panic
as an example. if I pass a structure that is supposed to implement the http.Handler interface and I haven't implemented ServeHTTP() on it, the IDE (say goland) will complain and ask me if I want to implement the missing functions. it does this by creating a function that just panics.
i.e.
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
panic("implement me")
}
I'm wondering if it wouldn't be better to be able to annotate interfaces to provide more valuable "Implement Me" implementations, which could then be used by IDEs
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(501)
_, _ = w.Write([]byte("Implement Me"))
}
of course its possible that people prefer implement me's that panic. one would also have to figure out how to deal with multiple templates provided by different interfaces that require the same function. (unsure so difficult, not so different than what happens when multiple imports seem to match and the IDE asks which one you want)