Packages

137 views
Skip to first unread message

Calvin Prewitt

unread,
Sep 23, 2011, 9:09:14 PM9/23/11
to google-appengine-go
Is the Go app in appengine restricted to having all of the app code in
a single package?
Or can you import a package within your app directory structure? If
so, how do you reference it?

Kyle Lemons

unread,
Sep 23, 2011, 9:23:25 PM9/23/11
to Calvin Prewitt, google-appengine-go
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".

Calvin Prewitt

unread,
Sep 23, 2011, 9:29:59 PM9/23/11
to google-appengine-go
Sweet. Got it to work. Thanks.

On Sep 23, 8:23 pm, Kyle Lemons <kev...@google.com> wrote:
> 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".
>

Adam Gessel

unread,
Sep 24, 2011, 12:44:09 PM9/24/11
to google-appengine-go
I was wondering the same thing and also got it to work. Thanks!

On Sep 23, 7:23 pm, Kyle Lemons <kev...@google.com> wrote:
> 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".
>
> On Fri, Sep 23, 2011 at 6:09 PM, Calvin Prewitt <calvin.prew...@gmail.com>wrote:> Is the Go app in appengine restricted to having all of the app code in
Reply all
Reply to author
Forward
0 new messages