mirror of
https://github.com/golang-standards/project-layout
synced 2024-11-17 03:25:58 +00:00
pkg dir origins
This commit is contained in:
parent
23bda496bb
commit
3d3c1d6333
@ -74,6 +74,8 @@ See the [`/pkg`](pkg/README.md) directory if you want to see which popular Go re
|
||||
|
||||
It's ok not to use it if your app project is really small and where an extra level of nesting doesn't add much value (unless you really want to :-)). Think about it when it's getting big enough and your root directory gets pretty busy (especially if you have a lot of non-Go app components).
|
||||
|
||||
The `pkg` directory origins: The old Go source code used to use `pkg` for its packages and then various Go projects in the community started copying the patteren (see [`this`](https://twitter.com/bradfitz/status/1039512487538970624) Brad Fitzpatrick's tweet for more context).
|
||||
|
||||
### `/vendor`
|
||||
|
||||
Application dependencies (managed manually or by your favorite dependency management tool like the new built-in [`Go Modules`](https://github.com/golang/go/wiki/Modules) feature). The `go mod vendor` command will create the `/vendor` directory for you. Note that you might need to add the `-mod=vendor` flag to your `go build` command if you are not using Go 1.14 where it's on by default.
|
||||
|
@ -4,10 +4,13 @@ Library code that's ok to use by external applications (e.g., `/pkg/mypubliclib`
|
||||
|
||||
It's also a way to group Go code in one place when your root directory contains lots of non-Go components and directories making it easier to run various Go tools (as mentioned in these talks: [`Best Practices for Industrial Programming`](https://www.youtube.com/watch?v=PTE4VJIdHPg) from GopherCon EU 2018, [GopherCon 2018: Kat Zien - How Do You Structure Your Go Apps](https://www.youtube.com/watch?v=oL6JBUk6tj0) and [GoLab 2018 - Massimiliano Pippi - Project layout patterns in Go](https://www.youtube.com/watch?v=3gQa1LWwuzk)).
|
||||
|
||||
Note that this is not a universally accepted pattern and for every popular repo that uses it you can find 10 that don't. It's up to you to decide if you want to use this pattern or not. Regardless of whether or not it's a good pattern more people will know what you mean than not. It is a bit confusing for new Go devs, but it's a pretty simple confusion to resolve and that's one of the goals for this project layout repo.
|
||||
Note that this is not a universally accepted pattern and for every popular repo that uses it you can find 10 that don't. It's up to you to decide if you want to use this pattern or not. Regardless of whether or not it's a good pattern more people will know what you mean than not. It might a bit confusing for some of the new Go devs, but it's a pretty simple confusion to resolve and that's one of the goals for this project layout repo.
|
||||
|
||||
Ok not to use it if your app project is really small and where an extra level of nesting doesn't add much value (unless you really want to). Think about it when it's getting big enough and your root directory gets pretty busy (especially if you have a lot of non-Go app components).
|
||||
|
||||
The `pkg` directory origins: The old Go source code used to use `pkg` for its packages and then various Go projects in the community started copying the patteren (see [`this`](https://twitter.com/bradfitz/status/1039512487538970624) Brad Fitzpatrick's tweet for more context).
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
* https://github.com/prometheus/prometheus/tree/master/pkg
|
||||
|
Loading…
Reference in New Issue
Block a user