google-app-engine - 找不到包 "appengine/cloudsql"

标签 google-app-engine go

我使用 Google Cloud SQL 和 MySQL 服务器开发了一些 GO 库。当我导入 `appengine/cloudsql 时,出现以下错误。

cloud.go:20:2: 在以下任何一个中找不到包“appengine/cloudsql”: /usr/local/Cellar/go/1.1.2/src/pkg/appengine/cloudsql(来自 $GOROOT) /Users/lameduck/myGo/src/appengine/cloudsql(来自 $GOPATH)

我知道这个包 appengine/cloudsql 仅适用于 Google App Engine,其他任何地方都不存在。

我想知道如何在单个库中将它用于 GAE 和其他环境的标准 sql 库。

PS:我可以正确设置 Google App Engine SDK。我的问题与此无关。我希望我的库可以同时在 Google App Engine 和独立环境中运行。 (我已经为 GAE 和其他数据库编写了代码。)用户必须设置一些配置是可以的。但我不希望用户必须修改库源代码。

感谢您的帮助。

最佳答案

我解决了这个问题。我用了 build constraint使用正确的例程并避免错误。 App Engine 存在构建约束,appengine .

The App Engine SDK introduces a new build constraint term: "appengine". Files that specify

// +build appengine will be built by the App Engine SDK and ignored by the go tool. Conversely, files that specify

// +build !appengine are ignored by the App Engine SDK, while the go tool will happily build them.

附言: Anway,我赞成其他答案。谢谢。

关于google-app-engine - 找不到包 "appengine/cloudsql",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19852395/

相关文章:

google-app-engine - Google App Engine 从父文件夹导入库

java - NoClassDefFoundError : com/google/appengine/api/urlfetch/ResponseTooLargeException

python - App Engine/Python/Django 非 JSON 上的身份验证

regex - 前瞻和后向正则表达式

go - Aerospike 测试环境

go - 如何使用 gdb 或 delve 将断点设置到 go 方法

golang 下载文件并遵循重定向

google-app-engine - Pinterest 拒绝来自 Google App Engine 的访问 (403)

multithreading - 继续 OS X - 两个库调用系统函数

python - 通过 Google Cloud Endpoints 将 UIImage 上传到 AWS S3