go get | package appengine: unrecognized import path "appengine" - google-app-engine

I have a package hosted on github which uses appengine sdk . When I do go get github.com/myself/mynicepackage I get an error
package appengine: unrecognized import path "appengine"
Question : How can I get this package using go get ?

There is no way to download it via go get.
go get works with source code repositories, but Google App Engine SDK is provided via .zip archives.
The only possible way to get Google App Engine SDK is to download it from here and install it manually.

Related

Intellij Keeps Telling Me "App Engine SDK path is not correct.'

Trying to deploy my first Google Cloud Java app using Intellij. I've followed and read so many threads and have gotten absolutely nowhere on what is seemingly one of the simplest steps of getting this set up. I have installed gcloud CLI and followed the instructions here. After installing, I run the commands 'gcloud components update' and 'gcloud components install app-engine-java'. I see the folder located in both 'C:\Users<username>\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine' and 'C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine'. I installed as multi user after hours of trying to get the single user install working, so now I have both. When in Intellij I am creating a new Google App Engine project under Java EE, it asks to specify a Google app engine SDK. There are no options so I choose to select the path. I have tried both above paths and it only tells me 'App Engine SDK path is not correct'. What am I doing wrong?? The steps seem ridiculously simple and it just doesn't work.
You stopped at the general google app engine folder
You need to specify the full path to the java-sdk folder, see the image in this question.

How do i use third party Go libraries with google app engine's development server?

In one of my .go files I have:
import (
...
"github.com/stripe/stripe-go"
"appengine"
"appengine/datastore"
)
But when i run dev_appserver.py app.yaml I get the following error:
Can't find package "github.com/stripe/stripe-go" in $GOPATH
I've tried running go get github.com/stripe/stripe-go which I can see successfully installs to ~/go/src/github.com/stripe/stripe-go but the GAE dev server doesn't seem to look at that path for some reason.
gcloud app deploy works just fine, for what it's worth.
Got the same error while testing the import "github.com/stripe/stripe-go" and fixed it by following the steps here "EDIT":
export GOPATH=/home/user/go_project
And a sample.go file in the example app's directory contains the following import statement:
import (
...
"github.com/stripe/stripe-go"
"appengine"
"appengine/datastore"
)
Then the gcloud tool will look for the "stripe/stripe-go" package in the following location when you run or deploy the app:
/home/user/go_project/src/stripe/stripe-go
Once the above is done, the devserver should look at the proper path after you've run "go get github.com/my_repo/packagename". hope it helps

Errors with a Golang web app hosted in a Google App Engine environment; the app front-ends BigQuery

I built a Golang web app that front-ends a Google BigQuery project. The app has these imports
import (
"context"
"html/template"
"log"
"net/http"
"regexp"
"strings"
"strconv"
"cloud.google.com/go/bigquery"
"google.golang.org/api/iterator"
)
and a JSON file for the BigQuery security credentials. Locally, it works perfectly at localhost:8080. Then, I tried to host it with Google App Engine and I hit some bugs.
For Google App Engine deployment, I first installed Google Cloud SDK locally, I ran gcloud init, and I installed the
gcloud components install app-engine-go
bq
core
gsutil
gcloud
beta
app-engine-python
packages. I removed the main() function from main.go, and the project directory has a YAML file. I ran
gcloud config set project {correct project ID}
and in a DOS window, I ran
gcloud app deploy
at the project directory. I got this error (formatted for SO and to remove private information):
C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine>gcloud app deploy
ERROR: (gcloud.app.deploy)
Staging command
[C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\goapp-stager.exe
C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine\app.yaml
C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine
c:\-----\-----\appdata\local\temp\--------\--------]
failed with return code [1].
-------------------------------------STDOUT-------------------------------------
-------------------------------------STDERR-------------------------------------
2017/07/18 18:14:44 failed analyzing C:\Golang Web Dev\golang-web-dev-master\bigqueryApp_AppEngine:
cannot find package "google.golang.org/appengine/socket" in any of:
($GOROOT not set)
C:\Go Workspace\src\google.golang.org\appengine\socket (from $GOPATH)
GOPATH: C:\Go Workspace\src\google
I traced this bug down to the imported
"cloud.google.com/go/bigquery"
package; another “test” app without cloud.google.com/go/bigquery works OK using this technique. I tried to import the
google.golang.org/appengine/socket
package in the app and I got another compile error; it looks like this page says don’t even go there. Next, I tried the ideas in this vid using the original application, keeping the original main() function in main.go. I typed
gcloud app deploy
in a Cloud Shell window. I got this
$ ---_---------#---------------X------:~/bigqueryApp
$ gcloud app deploy
ERROR: (gcloud.app.deploy) Staging command [/google/google-cloud-sdk/platform/google_appengine/goroot-1.6/bin/go-app-stager
/home/---_---------/bigqueryApp/app.yaml /tmp/---------/---------]
failed with return code [1].
------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/07/18 21:30:23 failed analyzing /home/---_---------/bigqueryApp:
cannot find package "google.golang.org/api/iterator" in any of:
($GOROOT not set)
/home/---_---------/gopath/src/google.golang.org/api/iterator (from $GOPATH)
/google/gopath/src/google.golang.org/api/iterator
GOPATH: /home/---_---------/gopath:/google/gopath
error. The app clearly imports the iterator package. I researched / experimented / etc. to fix the bugs in both techniques but no luck. If someone has ideas re: how to fix these bugs, I’d like to know them and I’d be grateful.
Thank you!
Solution:
1) Remove the "context" import
2) Import "google.golang.org/appengine"; see
[https://github.com/golang/appengine/blob/master/README.md][1]
for more details re: the local appengine package installation
3) This function
http.HandleFunc("/", bqPage)
calls
bqPage(w http.ResponseWriter, req *http.Request)
as the handler function. Pass that second req parameter down to the code that builds / calls the bigquery client:
ctx := appengine.NewContext(req)
// Get the projectID value from the Google Cloud Console:
projectID := "--------------"
// Create a client.
client, err := bigquery.NewClient(ctx, projectID)
Once you have the client object, you're in business.
4) From a DOS window pointed to the directory hosting the main.go file, run
gcloud app deploy
and then run the app with
gcloud app browse

build constraint app engine golang

Im pretty new to go and to the the app engine ,
I got this error cannot find package "appengine" .
so i researched a little bit and i found out about build constraint
cannot find package "appengine/cloudsql"
I tried to solve it by this commands .
go build -v -tags +build appengine
But i got the same error package appengine: cannot find package "appengine" .
I can run the goapp server and deploy app to the app engine
But i cant build or get the auto complete of the app engine library
thanks,
miki
You just need to use -tags appengine, and in the file that needs to just work on appengine you can start it with:
// +build appengine
package someName

ImportError: cannot import name taskqueue

I am trying to use AppEngine TaskQueue API, so I import it like this:
from google.appengine.api import taskqueue
The code works perfectly online. But when I try to run it locally, I get this error:
ImportError: cannot import name taskqueue
I checked the directory of AppEngine and I didn't find the file taskqueue.py which explains the error. Is there any reason why this file isn't included in the AppEngine SDK? And is there anyway to install it locally? I wouldn't trust just copying the file to the folder, because I am sure it depends on tens of other files.
Download and install the current SDK. You're using an older version.
OK, I found the solution for this myself. I just downloaded the latest AppEngine SDK (version 1.4) and it has the taskqueue.

Resources