找不到包“appengine / cloudsql” [英] cannot find package "appengine/cloudsql"

查看:582
本文介绍了找不到包“appengine / cloudsql”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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




cloud.go:20:2:can not find package appengine / cloudsql:
/usr/local/Cellar/go/1.1.2/src/pkg/appengine/cloudsql(from $ GOROOT)
/ Users / lameduck / myGo / src / appengine / cloudsql(来自$ GOPATH)



我知道这个包, appengine / code>,仅适用于Google App Engine,并且在其他地方不存在。



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



PS:我可以正确设置Google App Engine SDK。我的问题与它无关。我希望我的图书馆能够在Google App Engine和独立环境中运行。 (我已经为GAE制作了一个代码,并为其他数据库编写了代码)。用户必须设置一些配置才行。但我不希望用户必须修改库源代码。



感谢您的任何帮助。

解决方案

我解决了这个问题。我使用了构建约束来使用正确的例程并避免出现错误。 App Engine有一个构建约束, appengine


App Engine SDK引入了新的构建约束条件:
appengine。指定



// +构建appengine的文件将由App Engine SDK构建,并由
go工具忽略。相反,指定



// + build!appengine的文件被App Engine SDK忽略,而
工具则很乐意构建它们。


PS:
Anway,我提出了其他答案。谢谢。


I develop some GO libraries using Google Cloud SQL and MySQL server. When I imported `appengine/cloudsql, an error below occured.

cloud.go:20:2: cannot find package "appengine/cloudsql" in any of: /usr/local/Cellar/go/1.1.2/src/pkg/appengine/cloudsql (from $GOROOT) /Users/lameduck/myGo/src/appengine/cloudsql (from $GOPATH)

I know this package, appengine/cloudsql, is only for Google App Engine and it doesn't exist on everywhere else.

I'm wondering how can I use it for GAE and standard sql library for other environments in a single library.

PS: I can setup Google App Engine SDK correctly. My question is not relevant to it. I hope my library runs on Google App Engine and standalone environment together. (I already made a code for GAE and a code for other dabatases.) It is Ok that users have to setup some configurations. But I don't want that users have to modify a library source code.

Thanks for any help.

解决方案

I solved the problem. I used a build constraint to use the proper routine and avoid an error. There is a build constraint for 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.

PS: Anway, I upvoted other answers. Thank you.

这篇关于找不到包“appengine / cloudsql”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆