depで"does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)"のエラー

プライベートのプロジェクトで"dep ensure -add github.com/xxx"すると以下のエラーが出た。

Solving failure: No versions of github.com/xxx met constraints:
	0.1.1: Could not introduce github.com/xxx@master, as its subpackage github.com/xxx does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)



"does not contain usable Go code"から分かる通り、これは指定したリポジトリのルートディレクトリにGoのコードが存在しないのが原因みたい。
https://github.com/golang/dep/issues/1306#issuecomment-339864942

なのでgoのコードがあるパッケージを指定すればよいらしい。
https://github.com/golang/dep/issues/1306#issuecomment-374789539

ということで、Goのコードがあるパッケージ"yyy"を指定して"dep ensure -add github.com/xxx/yyy"してみるとvendorに対象パッケージが置かれた。

$dep ensure --add github.com/xxx/yyy
Fetching sources...

"github.com/xxx/yyy" is not imported by your project, and has been temporarily added to Gopkg.lock and vendor/.
If you run "dep ensure" again before actually importing it, it will disappear from Gopkg.lock and vendor/.



ちなみに、Gopkg.tomlの"required"にパッケージを指定することでもパッケージをvendorに配置することができる。
"required"は"Goのコードから参照されないけど必要になるパッケージを指定する機能"らしい。
https://github.com/golang/dep/issues/1306#issuecomment-384678415

ただ、この方法はGopkg.tomlに設定を追記するので"dep ensure"しないと対象パッケージがvendorに配置されないので、
"dep ensure -vendor-only"でGopkg.lockからvendorを生成したい場合には使えない。