如何为Google App Engine的GoClipse项目添加外部软件包?

如何为Google App Engine的GoClipse项目添加外部软件包?

问题描述:

I've compiled Goauth so that I can use OAuth in my Go Google App Engine project. Where do I put the goauth.a file so that I can both use it in the project, and have it available when deploying to the GAE servers? I can get it working locally if I put it in a subfolder of $GOROOT/pkg, but then it can't be found when compiling at deployment time.

GoClipse sets up a project with lots of folders, I'm not really sure what their purpose is, where should I put goauth.a and how do I import it?

我已经编译了Goauth,以便可以在Go Google App Engine项目中使用OAuth。 我将goauth.a文件放在哪里,以便既可以在项目中使用它,又可以在部署到GAE服务器时使用它? 如果将其放在$ GOROOT / pkg的子文件夹中,则可以在本地工作,但是在部署时进行编译时找不到它。 p>

GoClipse使用 很多文件夹,我不太确定它们的用途是什么,应该将goauth.a放在哪里以及如何导入它? p> div>

To fix this I ended up including the source for the package in the directory tree for my app, as mentioned in this thread on the google-appengine-go group http://groups.google.com/group/google-appengine-go/browse_thread/thread/1fe745debc678afb

Here is the important part of the thread:

You may include as many packages as necessary. Packages are imported by path relative to the base directory (the one that has your app.yaml file), so if you have the following:

helloworld/app.yaml
helloworld/hello/hello.go // package hello
helloworld/world/world.go // package world

you can import "world" in hello and import "hello" in world.

If you are including a third-party library, it might look something like this:

helloworld/app.yaml
helloworld/hello/hello.go // package hello
helloworld/world/world.go // package world
helloworld/goprotobuf.googlecode.com/proto/*.go // package proto

Then you can, as normal, import "goprotobuf.googlecode.com/proto".