Skip to content

net/http: panic when a nil HandlerFunc is passed to http.HandleFunc #24297

Closed
@snowdusk

Description

@snowdusk

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.9.2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

amd64 linux

What did you do?

package main

import "net/http"

func main() {
    http.HandleFunc("/", nil)
    http.ListenAndServe(":8080", nil)
}

What did you expect to see?

when I go run this file, the nil error appears not in compilation time but in run time. The reason is that http.Handler(http.HandlerFunc(nil)) == nil is false. BUT use reflect we can know the value of http.Handler(http.HandlerFunc(nil)) is nil, so the error should be stopped in compilation time by fix Handle function.

What did you see instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions