A package name identifies what a Go package provides. Choose a short, concise, expressive, single lowercase word rather than naming the package after its contents. section 2.12.2
Avoid these common package-naming mistakes:
- Do not create a meaningless utility package named util, common, shared, or base; use an expressive name such as stringset. section 2.13
- Do not force dozens of tiny packages or one huge package; balance cohesion, readability, and the meaning communicated by the name. section 2.12.2 section 2.13
- Do not shadow a package name with a variable: redis := redis.NewClient() makes redis refer to the variable throughout its scope. section 2.14
Replace a generic utility name
A generic API such as util.NewStringSet("c", "a", "b") and util.SortStringSet(set) hides its purpose. Rename the package to stringset and shorten its functions: stringset.New("c", "a", "b") and stringset.Sort(set). A dedicated Set type can simplify the client further: set := stringset.New("c", "a", "b"); set.Sort().
Resolve a package collision
Prefer a distinct variable name: redisClient := redis.NewClient(). If redis must remain the variable name, alias the import instead: import redisapi "mylib/redis"; redis := redisapi.NewClient(). Avoid dot imports because removing the package qualifier can increase confusion. section 2.14
/net
/http
client.go
...
/smtp
auth.go
...
addrselect.go
...
Browse a standard-library package layout to see how related capabilities receive focused package names. section 2.12.2
