Building BadgerDB v3 with Bazel fails

What version of Go are you using (go version)?

$ go version
go version go1.14.7 linux/amd64

What operating system are you using?

Linux code-0 5.4.0-62-generic #70-Ubuntu SMP Tue Jan 12 12:45:47 UTC 2021 x86_64 GNU/Linux

What version of Badger are you using?

v3@head

Does this issue reproduce with the latest master?

Yes

Steps to Reproduce the issue

Import BadgerDB via Bazel in another Go program, like so:

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "database",
    srcs = ["database.go"],
    importpath = "your/import/path", # Masked for this issue/bug report.
    visibility = ["//visibility:public"],
    deps = ["@com_github_dgraph_io_badger_v3//:badger"],
)

What Badger options were set?

None/NA

What did you do?

I built Badger as a dep via Bazel using bazel build package:target, i.e. bazel build database:database

What did you expect to see?

A successful build.

What did you see instead?

Use --sandbox_debug to see verbose messages from the sandbox builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src external/com_github_dgraph_io_badger_v3/backup.go -src ... (remaining 93 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
external/com_github_dgraph_io_badger_v3/batch.go:115:15: kv.Unmarshal undefined (type *pb.KV has no field or method Unmarshal)
external/com_github_dgraph_io_badger_v3/key_registry.go:198:18: dataKey.Unmarshal undefined (type *pb.DataKey has no field or method Unmarshal)
external/com_github_dgraph_io_badger_v3/key_registry.go:407:18: k.Marshal undefined (type *pb.DataKey has no field or method Marshal)
external/com_github_dgraph_io_badger_v3/stream.go:466:15: kv.Unmarshal undefined (type *pb.KV has no field or method Unmarshal)
external/com_github_dgraph_io_badger_v3/stream.go:476:29: kv.Size undefined (type *pb.KV has no field or method Size)
external/com_github_dgraph_io_badger_v3/stream.go:477:10: not enough arguments in call to y.Check2
external/com_github_dgraph_io_badger_v3/stream.go:477:13: kv.MarshalToSizedBuffer undefined (type *pb.KV has no field or method MarshalToSizedBuffer)
external/com_github_dgraph_io_badger_v3/stream_writer.go:99:15: kv.Unmarshal undefined (type pb.KV has no field or method Unmarshal)
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/compile: exit status 2
Target //cmd:cmd failed to build