I wanted to create my first Go web application on App Engine but wasn't sure how to structure my project.
The first step in laying out my project involved reading the following articles:
I wanted to follow the guidelines as described in the "How to Write Go Code" document but also create my project in a way that would be easy to build a web application that can be deployed on App Engine. I decided to split my website into two git repositories.
The first repo would be the website itself and all associated code. This app is responsible for handling requests and saving data to the datastore. The second repository would contain my business logic that would be used for the website as a library. The reason for separating the business logic is that the library may be used in other applications, other than a web app.
I eventually ended up with the following project structure:
├── projects ├── bin ├── pkg ├── src ├── github.com ├── alexchan ├── careermatchme │ ├── setup.txt │ └── web │ ├── app.go │ ├── app.yaml │ ├── static │ │ ├── css │ │ ├── img │ │ └── js │ └── templates │ ├── 404.html │ ├── 500.html │ ├── base.html │ └── jobsearch │ ├── about.html │ ├── includes │ │ ├── pagination.html │ └── search │ ├── form.html │ └── results.html └── jobs ├── jobs.go └── jobs_test.go
The top-level directory, projects, is where my Go workspace and is where my GOPATH environment variable is set to. My two repositories are under github.com/alexchan/careermatchme and github.com/alexchan/jobs. This allowed me to follow to conventions of described in the first article while setting up my environment to also develop and deploy for App Engine.