douban2014 2013-11-08 05:43
浏览 78
已采纳

找不到软件包“ appengine / cloudsql”

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.

  • 写回答

2条回答 默认 最新

  • dsfasdfsda234234 2013-11-08 15:54
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?