我有一个简单的go程序,我想在其中导入和使用bigtable sdk。
数据库.go
import (
"context"
"cloud.google.com/go/bigtable
)
func (s *Store) readRow(ctx context.Context) {
_,_ = bigtable.NewAdminClient(ctx, "bt-ded", "")
}
在构建文件中,我已经声明了依赖关系
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "datastore_pkg",
srcs = [
"bigtable/database.go",
"rpc/activity_rpc.go",
"rpc/index_rpc.go",
"rpc/user_rpc.go",
],
importpath = "github.com/cliqueedge/go/storage/datastore",
deps = [
"//protos/v1:datastore_go_grpc",
"@com_google_cloud_go//:go_default_library",
],
)
我不确定为什么会出现以下错误:
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: missing strict dependencies:
/private/var/tmp/_bazel_satyajit/bf73d00d74a5d5353f57b19b76b99eab/sandbox/darwin-sandbox/4609/execroot/__main__/storage/datastore/bigtable/database.go: import of "cloud.google.com/go/bigtable"
No dependencies were provided.
Check that imports in Go sources match importpath attributes in deps.
更改依赖关系
"@com_google_cloud_go//:go_default_library",
到
"@com_google_cloud_go_bigtable//:go_default_library",
也没有解决问题。
在这种情况下,我收到以下错误
no such package '@com_google_cloud_go_bigtable//': The repository '@com_google_cloud_go_bigtable' could not be resolved: Repository '@com_google_cloud_go_bigtable' is not defined and referenced by '//storage/datastore:datastore'
https://github.com/bazelbuild/rules_go
遵循本指南解决了我的问题。