Yes. But that's the thing - if what the function actually takes a duration, then the correct type is a duration. But the type `http.HandleFunc` takes is *not* a `http.HandlerFunc`, it's a `func(http.ResponseWriter, *http.Request)`. It's a different type and it's the correct type to describe what that function is for. If the type was `http.HandlerFunc`, then `http.HandleFunc` wouldn't need to exist, because `http.Handle` would suffice.
For example, if you had a function
// DurationFromMS returns a time.Duration, based on a duration given as an integer in ms.
func DurationFromMS(d int64) time.Duration {
return time.Duration(d * 1000)
}
Would you make the parameter type `time.Duration`? After all, it represents a duration, right? But you wouldn't. It would be the wrong type to represent what the function does.
Or, a different example: We could introduce a new type in the `filepath` package:
// Path is a path, using the OS-specific delimiter
type Path string
// Verify makes sure that p is a path, using the correct, OS-specific delimiter.
// It returns p as a Path, and an error, if p was invalid.
func Verify(p string) (Path, error)
We could then have `filepath.Join` etc. take `Path`s, instead of `string`s, to represent that the argument actually must be a valid path, using the OS-specific separator. Which would be different from `path.Path`, of course, which would always use "/" as a separator. Meaning you wouldn't be able to accidentally use one as the other, which would add type-safety.
But should `Verify` take a `Path` here? Of course not. That would be the wrong type. It just returns its argument converted into the correct type, but semantically, it still takes *a plain string*. Before you pass the path into `Verify`, it doesn't have the semantic association of "this string is an OS-specific path" - that's exactly the semantic association that `Verify` creates.
Your argument hinges on the assumption that `http.HandleFunc`s parameter has the semantic interpretation (not only the same underlying type as) as `http.HandlerFunc`. But it doesn't. The semantic interpretation of the argument to `http.HandleFunc` is a plain function. Otherwise, it wouldn't need to exist - because we already *have* a function that can take a `http.HandlerFunc`: `http.Handle`.
The plain func is describing exactly the type that function should take. `http.HandlerFunc` would be the wrong type.