A picture is worth a thousand words, so let’s look at a sample
The sample repository is here: github.com/constabulary/example-gsftp.
Clone this project, checking out the code anywhere that you like. There is no requirement to check it out inside your
% cd $HOME/devel % git clone https://github.com/constabulary/example-gsftp Cloning into ‘example-gsftp’…
Let’s have a look at the project on disk:
% cd example-gsftp % tree -d $(pwd) /home/dfc/devel/example-gsftp ├── src │ └── cmd │ └── gsftp └── vendor └── src ├── github.com │ ├── kr │ │ └── fs │ └── pkg │ └── sftp │ └── examples │ ├── buffered-read-benchmark │ ├── buffered-write-benchmark │ ├── streaming-read-benchmark │ └── streaming-write-benchmark └── golang.org └── x └── crypto └── ssh ├── agent ├── terminal ├── test └── testdata
You can build the project with
gb prints out each package’s name as it compiles it.
% gb build github.com/kr/fs golang.org/x/crypto/ssh golang.org/x/crypto/ssh/agent github.com/pkg/sftp cmd/gsftp
This project contains a “command” package,
cmd/gsftp, which is built and copied to
Note: Your commands don’t need to live in
$PROJECT/src/cmd, but you cannot place source at the root of
$PROJECT/src because that package would not have a name.
This project uses
gb-vendor to manage its dependencies, so let’s have a look at what has been vendored.
% gb vendor list github.com/kr/fs https://github.com/kr/fs master 2788f0dbd16903de03cb8186e5c7d97b69ad387b golang.org/x/crypto/ssh https://go.googlesource.com/crypto/ssh master c10c31b5e94b6f7a0283272dc2bb27163dcea24b github.com/pkg/sftp https://github.com/pkg/sftp master f234c3c6540c0358b1802f7fd90c0879af9232eb
Read more about getting started or setting up a gb project.