Where does GO look for google-cloud-sdk ? What should GOPATH be? - google-app-engine

I'm having trouble setting up Go App engine on osX. Should the google-cloud-sdk path be in GOROOT or GOPATH?
I put the google-cloud-sdk in /usr/local
It looks like there is source code in: goroot/
/usr/local/google-cloud-sdk/platform/google_appengine/goroot/
go env
GOPATH="/usr/local/google-cloud-sdk/platform/google_appengine/goroot"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
$ go get
package google.golang.org/appengine: cannot download, /usr/local/google-cloud-sdk/platform/google_appengine/goroot is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
package google.golang.org/appengine/datastore: cannot download, /usr/local/google-cloud-sdk/platform/google_appengine/goroot is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
When I attempted to change the PATH to include /src:
GOPATH="/usr/local/google-cloud-sdk/platform/google_appengine/goroot/src"
$ go get
package google.golang.org/appengine: mkdir /usr/local/google-cloud-sdk/platform/google_appengine/goroot/src/src: permission denied
package google.golang.org/appengine/datastore: cannot find package "google.golang.org/appengine/datastore" in any of:
/usr/local/go/src/google.golang.org/appengine/datastore (from $GOROOT)
/usr/local/google-cloud-sdk/platform/google_appengine/goroot/src/src/google.golang.org/appengine/datastore (from $GOPATH)
I appended the path to google-cloud-sdk to GOROOT:
export GOROOT="/usr/local/go/:/usr/local/google-cloud-sdk/platform/google_appengine/goroot"
GO doesn't seem to like multiple paths in GOROOT:
$ go get
go: cannot find GOROOT directory: /usr/local/go/:/usr/local/google-cloud-sdk/platform/google_appengine/goroot
I did run the ./install.sh script after I copied the source to /usr/local
The additional PATH's added did not fix the errors I was having.
I saw this answer: Test cases for go and appengine
But it's from 5 years ago and it seems clunky/hacky. It would seem in 5 years there would be a more elegant solution that copying individual directories and creating symlinks.
EDIT **********************
mv /usr/local/google-cloud-sdk/ ~/go/ then deleted GOPATH and GOROOT from .bash_profile
I then ran ./install.sh
I attempted to run 'go get':
$ go get
go install: no install location for directory /Users/Bryan/work/gocode/skincarereview outside GOPATH
Since that failed, I added the path to the working directory of code AND appended the path to google-cloud-sdk to PATH:
export GOPATH = "/Users/Bryan/work/gocode/skincarereview"
export PATH=$HOME/google-cloud-sdk:$PATH
go get get failed with the same message:
$ go get
go install: no install location for directory /Users/Bryan/work/gocode/skincarereview outside GOPATH
For more details see: 'go help gopath'

It goes in neither $GOROOT or $GOPATH. Just unpack it to your $HOME directory and run the installer. If necessary, add it to your $PATH by adding this line to your .bash_profile.
export PATH=$HOME/google-cloud-sdk:$PATH
Make sure you grab the golang SDK as well with gcloud components install app-engine-go https://cloud.google.com/appengine/docs/standard/go/download
DO NOT change your path to include the src dir in google-cloud-sdk/platform/google_appengine/goroot/src. That will break things. You leave your $GOPATH to be your normal installation. Using the App Engine SDK for Go automatically uses the sources in that dir without any manipulation.
Also, you should NEVER MANUALLY change $GOROOT unless you plan on compiling a new Go version from source (as in a new version of the language). It will automatically set the proper $GOROOT for you. https://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really
If your install is messed up beyond reason (happened to me once), just remove the cloud SDK and any references to it in your $PATH. Also completely uninstall the regular Go installation. Then start from scratch. Install Go, unpack google-cloud-sdk, run installer (add to $PATH if needed), gcloud components install app-engine-go. Voila.
When developing for App Engine, your go sources go into your REGULAR $GOPATH. They DO NOT go in google-cloud-sdk/... anywhere. To run the dev_appserver locally, run dev_appserver.py [path-to-source] where the given path contains your code and the app.yaml. I usually cd in to my project path (e.g. cd $HOME/go/src/myproject) and run with dev_appserver.py ./. https://cloud.google.com/appengine/docs/standard/go/tools/using-local-server
Deployment is covered here. https://cloud.google.com/appengine/docs/standard/go/tools/uploadinganapp
EDIT: Folder structure.
$GOPATH = $HOME/go
Location for google-cloud-sdk folder

Related

Your app is not on your GOPATH - deploying to app Engine go1.12

i have an problem with appengine and go112.
i can´t deploy without an error to the cloud:
2019/09/04 14:36:10 Copying /workspace/_gopath/src/mysql to /tmp/staging/srv/gopath/src/mysql
2019/09/04 14:36:10 Your app is not on your GOPATH, this build may fail.
2019/09/04 14:36:10 Building from Go source in /tmp/staging/srv, with main package at ./...
2019/09/04 14:36:10 Building /tmp/staging/srv, saving to /tmp/staging/usr/local/bin/start
2019/09/04 14:36:11 Wrote build output to /builder/outputs/output
2019/09/04 14:36:11 Failed to build app: Your app is not on your GOPATH, please move it there and try again.
building app with command '[go build -o /tmp/staging/usr/local/bin/start ./...]', env '[PATH=/go/bin:/usr/local/go/bin:/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=89fd1b631b04 HOME=/builder/home BUILDER_OUTPUT=/builder/outputs DEBIAN_FRONTEND=noninteractive GOROOT=/usr/local/go/ GOPATH=/go GOPATH=/tmp/staging/srv/gopath]': err=exit status 1, out=go build: cannot use -o with multiple packages.
PS C:\gopath\projects\gp-sql>
My project is under the gopath and i tried serveral modifications of it.
output of "go env"
set GOPATH=C:\gopath
set GOROOT=C:\golang
Anybody an idea what i´m missing?
Your project folder should be in "\src", not "\projects".
For standard Go setups, whatever your basic GOPATH environment variable points to, inside that folder should be a structure like:
bin/
# command executables
src/
github.com/golang/example/
.git/ # Git repository metadata
hello/
hello.go # command source
myproject1/
main.go # command source
main_test.go # test source
app.yaml # google cloud configuration
myproject2/
beepboop.go # command source
stringutil/
reverse.go # package source
reverse_test.go # test source
golang.org/x/image/
.git/ # Git repository metadata
bmp/
reader.go # package source
writer.go # package source
... (many more repositories and packages omitted) ...
This is a documented difference in the new version of go. Following this documentation should do the trick
If this doesn't work for you try creating a new GPATH folder, modify the Env Variable to make this folder you new gopath and put your application in the root of that folder.

Can't find dev_appserver.py with gcloud installation

I've installed gcloud by following the instructions on:
https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu
gcloud is in my path at /usr/bin/gcloud, but the package doesn't seem to have dev_appserver.py in my path. Is it installed? How do I run it?
Platform: Ubuntu 16.04
Edit: By running dpkg -L google-cloud-sdk I've found it at /usr/lib/google-cloud-sdk/bin/dev_appserver.py but when I try to run it I get:
This action requires the installation of components: [app-engine-
python]
You cannot perform this action because this Cloud SDK installation is
managed by an external package manager. If you would like to get the
Also not sure why it wasn't added to my path.
I know the original question concerns Ubuntu, but I just wanted to share some notes for macOS/OS X in case it's helpful for someone else.
I installed the google-cloud-sdk via Homebrew-Cask and overlooked the caveats note:
brew cask install google-cloud-sdk
After installing the SDK cask, I installed the Python App Engine component, as #Rodney Jonace mentioned:
gcloud components install -q app-engine-python
Going back to the caveats note mentioned above, I appended the following the my ~/.zshrc file:
source $(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc
source $(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc
Opening a new terminal tab, I was able to call the extra Python App Engine scripts (e.g., dev_appserver.py) and use the Zsh completions. Hope that helps!
The following articles were also useful:
http://www.javatronic.fr/tips/2014/10/17/installing_google_cloud_sdk_on_ubuntu_with_oh-my-zsh.html
http://www.rainbowbreeze.it/how-to-setup-a-google-app-engine-python-environment-on-mac-osx-using-homebrew/
The google-cloud-sdk deb package comes with the built-in component manager disabled, which is preventing that copy of dev_appserver.py from working through gcloud. If you update your apt-cache, you can install the google-cloud-sdk-app-engine-python and/or google-cloud-sdk-app-engine-java packages that have just started to be published. Directions here:
https://cloud.google.com/sdk/downloads#apt-get

Go 1.5+ : Error - imports runtime: C source files not allowed when not using cgo or SWIG

My program was building perfectly with go 1.4.2. After installing go 1.5, I am getting following error.
imports runtime: C source files not allowed when not using cgo or
SWIG: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c
mcache.c mcentral.c mem_linux.c mfixalloc.c mgc0.c mheap.c msize.c
os_linux.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c
signal_unix.c stack.c string.c sys_x86.c vdso_linux_amd64.c
The error is not program dependent. Even a "Hello world" programs is throwing the same error.
Remove Old 1.4.x go installation and then install go 1.5.
I faced the same problem after installing go 1.5. The issue is that I installed go 1.5 at the same place of 1.4.2. Go 1.5 does not use C anymore and if old C installation files are present it throws the error as you are shown.
if you want the old installation to be present as well then install 1.5 to some other location and set GOROOT to that location.
Hope it helps.
Edit 1: For Linux Users:
if you downloaded go1.5*.tar.gz then you did this:
tar -C /usr/local/ -xvf go1.5.linux-amd64.tar.gz
Your old folder C files are not deleted, so the correct process is:
First: You should delete you old go folder.
sudo rm -rf /usr/local/go/
Second: Then run
tar -C /usr/local/ -xvf go1.5.x.linux-amd64.tar.gz
If you use brew to upgrade your go to Go 1.5. Here is my step to make it work:
Remove pkg folder in %GOPATH%
Reload terminal(console) session, make sure Go env goes to Go 1.5 folder.
BTW: You need do the same thing if you want to switch from Go 1.5 back Go 1.4.2 via brew switch go 1.4.2.
I have the same problem because I installed two version of golang on my machine, one from offical site and the other is from homebrew.
And the GOROOT isn't match the go binary, I just replace the GOROOT with the right one, then done.
export GOROOT=/usr/local/opt/go/libexec # install via brew
I experienced this issue within my editor (sublime text 2). I call go build upon saving, it would appear my editor was pointing to go 1.4.x rather than the newly installed 1.5.
I solved this by simply quitting and reopening my editor.

Sencha Cmd broken: Why does 'app build' ignore any command line parameters?

I've upgraded Sencha cmd to v4 and I used to be able to build to a specific archive path and destination path. This was crucial as the build server removes the source code folder and archive path for each build. I had the paths output on the IIS server away from the build server, so that they are never lost.
However, my build process is failing now as the path parameters supplied to the sencha cmd don't do anything.
If I type:
Sencha help app build
I get the following help:
Syntax
sencha app build [options] [environment] \
[destination] \
[archive]
But supplying these parameters has no effect to the location of the output.
Can anyone point me to the documentation which shows if this has changed and how I rectify it. I can't find anything on the their site which shows how to build for production and have it output to separate paths. Also I'd like to know why the Sencha Tools change so much. This wreaks havoc on any existing build systems because things suddenly stop working.
See below:
C:\Development\Projects\IEApp>sencha app build --archive C:\temp\build\IEApp\bui
ldarchive --destination C:\temp\build\IEApp\Destination --environment production
Everything builds ok, but the C:\temp\build folder is empty.
I can not tell you where the doc is, but to get CMD to build to a different directory, this is what I do:
modify the file: .sencha\app\production.properties as follows:
# =============================================================================
# This file provides an override point for default variables defined in
# production.defaults.properties. These properties are only imported when building
# for the "production" environment.
#
# Properties defined in this file take priority over build.properties but are
# only loaded for "production" builds.
# =============================================================================
build.dir=${app.dir}/../../ExtJSApps/dashboard

Go: install drive v2 package cmd/cgo error

I'm trying to get the google drive package for go, but using the below always throws the error. Should I be installing it manually?
./go get code.google.com/p/google-api-go-client/drive/v2
load cmd/cgo: package cmd/cgo: no Go source files in .../google_appengine/goroot/src/cmd/cgo
The package seems to be broken. The basename of its import path (v2) doesn't match the package name found there (drive).
I'm not sure but I guess maybe some script which generates something is broken. I suggest to ask the committer at golang-nuts
You are appear to be looking in google_appengine directories. Why?
What is the output from these commands?
$ go version
$ go env
$ env | grep '^PATH'

Resources