Make bulk loader code available as a package

The bulk loader is actually available as a package: import "github.com/dgraph-io/cmd/bulk" . The datatypes have mostly unexported fields though. You are looking for the bulk.Bulk datatype (which is a x.SubCommand) to manage your bulk imports.

Bear in mind if you do use Viper/Cobra in your application, the package bulk will have some things that mess with the global state. It may be a bit tricky, but definitely doable.