Go Trick: Vendoring Non-Package Directory
After go version 1.13+, go mod -vendor prunes non-package directories from vendor. This is noted here:
https://github.com/golang/go/issues/26366
So, how do we include a non-package directory(sql migrations, yamls etc.) to be included in the vendor ?
Example directory:
|
|
migrations.go:
|
|
The conditionally compiled file migrations.go will force go mod -vendor to include it.