I am using a golang package, say name pkgfoo
; and the author explicitly said if we want to use a package subpkg
under pkgfoo
, I need to explicitly import subpkg. I don't understand the reason behind it. Isn't the subpkg automatically imported if I import the top pkg in Golang?
package main
import (
"myownpackage"
"github.com/usera/pkgfoo"
"github.com/usera/pkgfoo/subpkg"
)
func main() {
// Use functions in pkgfoo, and use functions in pkgfoo/subpkg
// ......
http.HandleFunc("/login", login)
err := http.ListenAndServe(":9090", nil) // setting listening port
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
My question is whether I really need import "github.com/usera/pkgfoo/subpkg"
statement.