Autocomplete for Google App Engine

Find Tips and tricks on how to better use the Zeus editor. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2449
Joined: Fri Aug 13, 2004 5:10 pm

Autocomplete for Google App Engine

Post by jussij » Sat Feb 14, 2015 3:19 am

To get the Zeus autocomplete to work with the Google App Engine will require some minor configuration, as outlined below:

Step 1: Installation

You will first need to have the Google App Engine installed on the machine.

The App Engine SDK for Go can be downloaded from this link:

https://cloud.google.com/appengine/down ... SDK_for_Go

Step 2: To install the software just extract the contents of the Zip file downloaded from the link above.

It really does no matter where the SDK is installed, as it is a fully contained environment.

Lets assume the zip file is extracted to this drive location:

Code: Select all

c:\
That extraction process will create this folder:

Code: Select all

c:\go_appengine
Step 3: Setting up the Environment
The App Engine SDK has it's own version of Go so we need to setup the GOPATH and GOROOT variables and while where are at it, lets add the App Engine to the PATH environment variable as well.

There are several ways this could be done, but the easiest is to create a simple batch file.

Save the batch commands shown below to the c:\go_appengine\zae.cmd file and create a short cut to that file on the desktop.

Code: Select all

@echo off

rem Setup the Go App Engine environment
set PATH=c:\go_appengine\;%PATH%
set GOROOT=c:\go_appengine\goroot
set GOPATH=c:\go_appengine\gopath

rem Run a new instance of Zeus using those settings
start "" "C:\Program Files (x86)\Zeus\zeus.exe" -s
This batch file sets up the environment variables for the App Engine and starts a new instance of Zeus.

Step 4: Tell Gocode About the App Engine
The App Engine used the suffix option when it created its packages and that stops gocode from finding those packages.

For example depending on the CPU type, the App Engine will install package folders similar to these:

Code: Select all

c:\go_appengine\goroot\pkg\windows_386_appengine
c:\go_appengine\goroot\pkg\windows_amd64_appengine
But gocode is not expecting the suffix options and as such it is only looking for packages in these locations:

Code: Select all

c:\go_appengine\goroot\pkg\windows_386
c:\go_appengine\goroot\pkg\windows_amd64
To fix this just use the mklink command to create a symbolic link, thus allowing gocode to find the packages.

That is the setup complete. More details about using the App Engine can be found here:

https://cloud.google.com/appengine/docs ... ngstarted/

Note: goimports vs gofmt
Zeus is configured to run goimports on any file save action and in doing this test it was noted goimports can be a little slow when checking App engine code.

If this slowness becomes an issue it can be easily fixed by editing the Go document type and replacing the current goimports save trigger:

Code: Select all

$zud\zScript\go_imports.lua
with the much faster go fmt script:

Code: Select all

$zud\zScript\go_fmt.lua
Testing the Install
To test the installation above start a new instance of Zeus using the shortcut created on the desktop.

Create a new MyApp folder at the following GOPATH folder location:

Code: Select all

c:\go_appengine\gopath\MyApp
In that folder create some App Engine MyApp.go code as follows:

Code: Select all

package guestbook

import (
	"net/http"

	"appengine"
)

func root(w http.ResponseWriter, r *http.Request) {
	c := appengine.
}
And now you have App Engine autocomplete inside of Zeus:

Image

jussij
Site Admin
Posts: 2449
Joined: Fri Aug 13, 2004 5:10 pm

Autocomplete for Google App Engine

Post by jussij » Sat Feb 14, 2015 12:21 pm

In the above example a symbolic link was used to locate the missing App Engine packages.

But it turns out there is an easier fix ;)

At the command prompt if you run this command:

Code: Select all

gocode set
You should see this output:

Code: Select all

propose-builtins false
lib-path ""
autobuild false
Here is the description of the lib-path option.

lib-path
A string option. Allows you to add search paths for packages. By default, gocode only searches $GOPATH/pkg/$GOOS_$GOARCH and $GOROOT/pkg/$GOOS_$GOARCH in terms of previously existed environment variables. Also you can specify multiple paths using ':' (colon) as a separator (on Windows use semicolon ';'). The paths specified by lib-path are prepended to the default ones.

So an alternative to creating a symbolic link is to run this command:

Code: Select all

gocode set lib-path c:\go_appengine\goroot\pkg\windows_amd64_appengine
That command tells gocode where to locate the missing packages :)

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 1 guest