简体   繁体   English

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

[英]How do you add an external package to a GoClipse project for Google App Engine?

I've compiled Goauth so that I can use OAuth in my Go Google App Engine project. 我已经编译了Goauth,以便可以在Go Google App Engine项目中使用OAuth。 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? 我将goauth.a文件放在哪里,以便既可以在项目中使用它,又可以在部署到GAE服务器时使用它? 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. 如果将它放在$ GOROOT / pkg的子文件夹中,则可以使其在本地运行,但是在部署时进行编译时找不到它。

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? GoClipse设置了一个包含很多文件夹的项目,我不太确定它们的用途是什么,应该将goauth.a放在哪里以及如何导入它?

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 为了解决此问题,我最终在Google-appengine-go组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: 包是通过相对于基本目录(具有app.yaml文件的目录)的路径导入的,因此,如果您具有以下内容:

helloworld/app.yaml helloworld / app.yaml
helloworld/hello/hello.go // package hello helloworld / hello / hello.go //包hello
helloworld/world/world.go // package world helloworld / world / world.go //封装世界

you can import "world" in hello and import "hello" in world. 您可以在hello中导入“世界”,在世界中导入“ hello”。

If you are including a third-party library, it might look something like this: 如果您包含第三方库,它可能看起来像这样:

helloworld/app.yaml helloworld / app.yaml
helloworld/hello/hello.go // package hello helloworld / hello / hello.go //包hello
helloworld/world/world.go // package world helloworld / world / world.go //封装世界
helloworld/goprotobuf.googlecode.com/proto/*.go // package proto helloworld / goprotobuf.googlecode.com / proto / *。go //打包proto

Then you can, as normal, import "goprotobuf.googlecode.com/proto". 然后,您可以像往常一样导入“ goprotobuf.googlecode.com/proto”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM