The relationship of packages in go language

A go package is actually a directory, so what"s the difference between a net package and a net/http package? is there a dependency between a http package located in a directory under the net package at the same level as the code file of the net package? Or this layout structure, is there an equal relationship between the two?

Apr.07,2021

there is no inevitable relationship between the file name and the package name. The path is filled in the import, and the package name is entered when the call is made. There can only be one package name in a file directory. For example, a net package can have multiple package names in a multi-tier structure. Golang does not support circular references. Designing this hierarchical relationship can avoid circular references. To put it simply, the higher the directory is, the lower the code is.


should include the parent-subset relationship, but it is not a dependency relationship, it is just a division of modularization, which is more specifically divided by module.


dependency, net depends on net/http

Menu