I wrote this repository, because every time I went to start a new Go project on Google App Engine I couldn't remember an optimal way to structure my application and how to manage my GOPATH in relation to my application code.
This repository aims to show several options for managing GOPATHs when working with a Go App Engine projects.
It assumes that you already have the Google Cloud Platform SDK installed.
If you have a different way that you feel is appropriate, pull requests are more than welcome.
It should be noted that while this repository makes relatively heavy use of Make, you only need to be able to run Make commands, not understand the files (but it is a useful thing to know!)
For a full description of what this repository is showing read the full blog post.
Except for the GB tasks, the GOPATH is controlled within the Makefiles that are in this project. This means you can run any of the Make tasks in this project to test them out, without having to change a GOPATH you already have set.
- Clone the repository:
git clone https://github.com/markmandel/appengine-golang-gopath.git
cd appengine-golang-gopath
- Install the go tooling we use for this:
make install-tools
- Enter the directory:
cd src/modules/basic
- Review the
routes.go
file to see what is being executed:cat routes.go
- Have a look at the current GOPATH:
make debug-env
- Install all dependencies
make deps
- Have a look where those dependencies end up in the directory structure:
(cd ../.. && pwd && ls)
- Run the module:
make serve
- Browse to http://localhost:8080 to see the results.
- (Optional) - Deploy the module:
make deploy
- Have a look at the local
Makefile
andMakefile.goapp
to see how the steps worked:cat Makefile
andcat ../../../Makefile.goapp
- Enter the directory:
cd ../vendored
- Clean the previous dependencies:
make clean
- Review the
routes.go
file to see what is being executed:cat routes.go
- Have a look at the current GOPATH:
make debug-env
. Notice the two part GOPATH. - Install all dependencies
make deps
- Have a look where those dependencies end up in the directory structure:
(cd ../../../vendor/src && pwd && ls)
- Run the module:
make serve
- Browse to http://localhost:8080 to see the results.
- (Optional) - Deploy the module:
make deploy
- Have a look at the
Makefile.goapp
to see how the steps worked:cat ../../../Makefile.goapp
- Enter the directory:
cd ../gb
- Clean the previous dependencies:
make clean
- Review the
routes.go
file to see what is being executed:cat routes.go
- Have a look at the current GOPATH:
make debug-env
. Notice there is no GOPATH. Crazy. - Install all dependencies
make deps
- Have a look where those dependencies end up in the directory structure:
(cd ../../../vendor/src && pwd && ls)
- Have a look at the
manifest
file:cat ../../../vendor/manifest
. - Run the module:
make serve
- Browse to http://localhost:8080 to see the results.
- (Optional) - Deploy the module:
make deploy
- Have a look at the local
Makefile
andMakefile.gb
to see how the steps worked:cat Makefile
andcat ../../../Makefile.gb
Apache 2.0
This is not an official Google product.