In http package it is defined a custom type (type Dir string
) and then a method Open
is added to it (https://golang.org/src/net/http/fs.go#L34). When invoked elsewhere it is done by http.Dir(".")
as it were a function or method. Can someone explain me why and what is happening here?
http.Dir(".")
is a type conversion. It converts the string "."
to type http.Dir
.