Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
771 views
in Technique[技术] by (71.8m points)

google app engine - How to correctly import Golang appengine?

In my Google App Engine project written in Go I've been using e.g.

import "appengine/datastore"

with success for a long time and assuming the import locates things where I have the App Engine SDK. However, now I want to use a third party library also from Google that uses things from App Engine as well, but imports with the full path:

import "google.golang.org/appengine"

Running the app

$ goapp serve

fails with not finding appengine:

...go/src/golang.org/x/oauth2/client_appengine.go:16: can't find import: "google.golang.org/appengine/urlfetch"

Can't find package "google.golang.org/appengine" in $GOPATH

Obviously I want to use the same App Engine parts to not have other problems. My first through is that I want to tell the third party library to use the App Engine SDK libraries, but I don't know how as it has a different prefix in the import.

Should I use the full path in my project for all App Engine imports? This would be opposite to what is in all what I have read on the Google's App Engine for Golang webpages. E.g. here.

Generally, what is the way to set up things so that it finds the right appengine libraries both in development and production on App Engine as well as from third party libraries?

Thanks in advance for any help!

UPDATE

I can also see that after adding the third party library and running go get it fetched all kinds of stuff into $GOPATH/src/google.golang.org/api/.... Lots of stuff there and appengine as well etc. It seems to be all Golang Google APIs...!

So it's not resolved but I have learned that there's a change that changes to fully qualified appengine import paths.

Now I have my app running locally as I pulled in the new appengine to satisfy the oauth library that uses the new import paths.

go get google.golang.org/appengine

According to this:

If you don't want to update your entire app to use the new App Engine packages, you may use both sets of packages in parallel, using only the new packages with the oauth2 package.

Actually very confusing and I don't know what is available when I deploy on App Engine. Does anyone know?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...