en/13.1.md
Anything you intend to do well must first be planned well. In our case, our intention is to develop a blogging system, so the first step we should take is to design the flow of the application in its entirety. When we have a clear understanding of the our application's process of execution, the subsequent design and coding steps become much easier.
Let's proceed by assuming that our GOPATH points to a folder with an ordinary directory name (if not, we can easily set up a suitable directory and set its path as the GOPATH). As we've describe earlier, a GOPATH can contain more than one directory: in Windows, we can set this as an environment variable; in linux/OSX systems, GOPATH can be set using export, i.e: export gopath=/path/to/your/directory, as long as the directory which GOPATH points to contains the three sub-directories: pkg, bin and src. Below, we've placed the source code of our new project in the src directory with the tentative name beelog. Here are some screenshots of the Windows environment variables as well as of the directory structure.
Figure 13.1 Setting the GOPATH environment variable
Figure 13.2 The working directory under $gopath/src
Our blogging system will be based on the model-view-controller design pattern. MVC is the separation of the application logic from the presentation layer. In practice, when we keep the presentation layer separated, we can drastically reduce the amount of code needed on our web pages.
template package provides very good support for view layer functionality.The following figure is an overview of the project framework and demonstrates how data will flow through the system:
Figure 13.3 framework data flow
According to the framework flow we've designed above, our blog project's directory structure should look something like the following:
|——main.go import documents
|——conf configuration files and processing module
|——controllers controller entry
|——models database processing module
|——utils useful function library
|——static static file directory
|——views view gallery
In order to quickly build our blog, we need to develop a minimal framework based on the application we've designed above. The framework should include routing capabilities, support for RESTful controllers, automated template rendering, a logging system, configuration management, and more.
This section describes the initial design of our blogging system, from setting up our GOPATH to briefly introducing the MVC pattern. We also looked at the flow of data and the execution sequence of our blogging system. Finally, we designed the structure of our project directory. At this point, we've basically completed the groundwork required for assembling our framework. In the next few sections, we will implement each of the components we've discussed, one by one.