We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version 1.16
go env
$ go env
package main
type Element interface { Body() interface{} }
func test(e Element) { if e != nil { e.Body() } }
type Div struct{}
func (div Div) Body() interface{} { return "div" }
func getDiv() *Div { return nil }
func main() { // panic: value method main.Div.Body called using nil *Div pointer
// goroutine 1 [running]: // main.(*Div).Body(0x0, 0x647ae0, 0xc00001c0b8) // <autogenerated>:1 +0x53 // main.test(...) // main.go:9 // main.main() // main.go:34 +0x3b // exit status 2 test(getDiv())
}
No panic or forbbiden to compile
Panic
The text was updated successfully, but these errors were encountered:
The Go project doesn't use the issue tracker for questions. See https://golang.org/wiki/Questions.
Sorry, something went wrong.
Your error is related to https://golang.org/doc/faq#nil_error
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
package main
type Element interface {
Body() interface{}
}
func test(e Element) {
if e != nil {
e.Body()
}
}
type Div struct{}
func (div Div) Body() interface{} {
return "div"
}
func getDiv() *Div {
return nil
}
func main() {
// panic: value method main.Div.Body called using nil *Div pointer
}
What did you expect to see?
No panic or forbbiden to compile
What did you see instead?
Panic
The text was updated successfully, but these errors were encountered: