如何将外部包添加到GoClipse项目中以用于Google App Engine?

huangapple go评论88阅读模式
英文:

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

问题

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

GoClipse设置了一个带有许多文件夹的项目,我不太确定它们的目的是什么,我应该把goauth.a放在哪里,如何导入它?

英文:

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?

答案1

得分: 2

为了解决这个问题,我最终将包的源代码包含在我的应用程序的目录树中,就像在google-appengine-go组的这个帖子中提到的那样。以下是该帖子的重要部分:

> 您可以包含任意数量的包。包是相对于基本目录(包含您的app.yaml文件的目录)的路径导入的,所以如果您有以下内容:
>
> helloworld/app.yaml
> helloworld/hello/hello.go // 包hello
> helloworld/world/world.go // 包world
>
> 您可以在hello中导入“world”,在world中导入“hello”。
>
> 如果您要包含第三方库,可能会像这样:
>
> helloworld/app.yaml
> helloworld/hello/hello.go // 包hello
> helloworld/world/world.go // 包world
> helloworld/goprotobuf.googlecode.com/proto/*.go // 包proto
>
> 然后,您可以像正常情况下一样导入“goprotobuf.googlecode.com/proto”。

英文:

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".

huangapple
  • 本文由 发表于 2011年9月24日 07:19:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/7535803.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定